Time perception test

For everything that's not in any way related to PureBasic. General chat etc...
User avatar
Lunasole
Addict
Addict
Posts: 1091
Joined: Mon Oct 26, 2015 2:55 am
Location: UA
Contact:

Time perception test

Post by Lunasole »

Hi.
Recently I was interested a bit how perception of time changes with age.
Additionally made simple program for some related test.

The results of that 1-minute test generally saying almost nothing (as they may depend on mood, for example), but anyway you can try ^^

Code: Select all

EnableExplicit
DisableDebugger

;{ Dialogs }

Global DialogsXML$ = #Empty$
DialogsXML$ +
"<dialogs>" +
"	<window name='window1' flags='#PB_Window_ScreenCentered|#PB_Window_SystemMenu'>" +
"		<vbox name='vbox1'>" +
"			<text name='text1' text='Press "Start", then wait as long as you think 1 minute has passed, then press "Stop":'/>" +
"			<hbox name='hbox1' expand='item:2'>" +
"				<button name='button1' text='Start' width='100'/>" +
"				<empty name='empty1'/>" +
"				<button name='button2' disabled='yes' text='Stop' width='100'/>" +
"			</hbox>" +
"			<string name='string1' flags='#PB_String_ReadOnly'/>" +
"		</vbox>" +
"	</window>" +
"</dialogs>"

	Global dlg_window1 = CreateDialog(#PB_Any)
	Global window1
	Global string1, button1, button2, text1
	
	Global State
	Global Time1
	
	Procedure e_button1()
		If State = 0
			; start
			State = 1
			DisableGadget(button1, #True)
			DisableGadget(button2, #False)
		EndIf
	EndProcedure
	
	; [button]        
	Procedure e_button2()
		Protected Res
		If state = 2
			; fin
			Res = AddDate(0, #PB_Date_Second, (ElapsedMilliseconds() - Time1) * 0.001)
			SetGadgetText(string1, FormatDate("%hh:%ii:%ss", Res) + " (" + StrF(Res / 60, 2) + ")")
			state = 0
			DisableGadget(button1, #False)
			DisableGadget(button2, #True)
		EndIf
	EndProcedure
	
	Procedure InitDialogs()
		Protected DialogsXML = ParseXML(#PB_Any, DialogsXML$)
		If OpenXMLDialog(dlg_window1, DialogsXML, "window1")
			window1 = DialogWindow(dlg_window1)
			string1 = DialogGadget(dlg_window1, "string1")
			button1 = DialogGadget(dlg_window1, "button1")
			button2 = DialogGadget(dlg_window1, "button2")
			text1 = DialogGadget(dlg_window1, "text1")
			
			BindGadgetEvent(button1, @e_button1())
			BindGadgetEvent(button2, @e_button2())
			
			RefreshDialog(dlg_window1)
		EndIf
		If IsXML(DialogsXML): FreeXML(DialogsXML): EndIf
		DialogsXML$ = #Empty$
	EndProcedure
;}


; Main
InitDialogs()
Repeat
	Define E = WaitWindowEvent(1)
	If E = #PB_Event_CloseWindow
		Break
	EndIf
	
	If state = 1
		Time1 = ElapsedMilliseconds()
		State = 2
	EndIf	
ForEver
"W̷i̷s̷h̷i̷n̷g o̷n a s̷t̷a̷r"