|
Post by (X) on Oct 23, 2023 16:06:42 GMT 1
I was dumb founded!
I've only been fiddling around for about 30 years with GFA-BASIC 32 for Windows and only just realized a different behaviour of the Sleep command for the compiled EXE vs RUN from IDE behaviour!
What's the diff?
I was happily relying on the runtime version until I tried the compiled version when I realized the different behaviour. The solution was simple enough. Create a Timer event that triggers at the desired rate. Now, I get the same behaviour in both versions.
|
|
|
Post by larrybtoys on Oct 27, 2023 21:16:10 GMT 1
Not sure if this is what you were looking to do but I use this Procedure in all my programs for a delay of 1000th of a second. I simply use the line LB_PAUSE(Fixed_Var,RAND_Var) and it works great. The RAND_Var is usually 0 unless I am writing AI and I want a random delay to simulate another human player.
Procedure LB_PAUSE(MAIN_P%, EXTRA_P%) Local JJ% JJ% = oTimer H_Pattern: If oTimer - JJ% < (MAIN_P% + EXTRA_P%) PeekEvent GoTo H_Pattern EndIf EndProcedure
|
|
|
Post by Roger Cabo on Oct 29, 2023 0:17:40 GMT 1
Not sure if this is what you were looking to do but I use this Procedure in all my programs for a delay of 1000th of a second. I simply use the line LB_PAUSE(Fixed_Var,RAND_Var) and it works great. The RAND_Var is usually 0 unless I am writing AI and I want a random delay to simulate another human player. Procedure LB_PAUSE(MAIN_P%, EXTRA_P%) Local JJ% JJ% = oTimer H_Pattern: If oTimer - JJ% < (MAIN_P% + EXTRA_P%) PeekEvent GoTo H_Pattern EndIf EndProcedure If you like to update your gb32 continuously and keep gb32 alive, you should create a Ocx timer by code. Or OcxOcx XXXX inside of a main form.
This will make sure your program works well, anyway if you open files and handle any mouse and keyboard inputs.
Otherwise your program will hang or stop.. any your never know why..
OpenW 1 Ocx Timer tmr tmr.Interval = 33 tmr.Enabled = True
Do Sleep Until Me Is Nothing
Sub tmr_Timer DoEvents // is required
// the following is fun only and not required Static counter% = 0 counter++ Text 0, 0, "Timer Event " & counter EndSub
|
|