QB64.org Forum

Active Forums => QB64 Discussion => Topic started by: krovit on February 03, 2020, 02:41:38 pm

Title: UEVENT alternative
Post by: krovit on February 03, 2020, 02:41:38 pm
Hi,

ON UEVENT is not supported by Qb64 (and maybe it never will be, I guess).

Question: Is there an alternative to observe the behavior of a variable?

In other words, I would like a certain function to be activated when a variable takes on a certain value.

Of course, just an IF or a GOSUB or another "manual" system that checks the value at each step but to do so it must be called continuously.

I would like the program to monitor the situation and act accordingly.

Maybe it already exists and I complicate things unnecessarily but at the moment I don't seem to remember anything that is right for me.



Title: Re: UEVENT alternative
Post by: FellippeHeitor on February 03, 2020, 03:33:43 pm
Use a timer. When the timer hits, check for the variable value and launch the procedure.

http://www.qb64.org/wiki/ON_TIMER(n)
Title: Re: UEVENT alternative
Post by: krovit on February 04, 2020, 05:09:06 am
Thanks Filippe, Thanks, I will try to implement this function that I already use elsewhere.
Title: Re: UEVENT alternative
Post by: TempodiBasic on February 07, 2020, 04:04:19 pm
my 2 cents

moreover you can manage manually a loop like timer or FPS and trigger the event as you need in your code.

for example

Quote
DO
_LIMIT 50 ' it gives 50 action per second to this program
FPS = FPS +1
if  FPS = 30 then FPS = 0
if FPS = 25 then Trigger UEvent1 (call the SUB/Function)

LOOP UNTIL QUIT$ = True
END

SUB UEvent 1
'what you need to do
END SUB
Title: Re: UEVENT alternative
Post by: krovit on February 08, 2020, 04:15:38 am
2 cents interesting... thank you