Author Topic: UEVENT alternative  (Read 2810 times)

0 Members and 1 Guest are viewing this topic.

Offline krovit

  • Forum Regular
  • Posts: 179
    • View Profile
UEVENT alternative
« 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.



Nothing is easy, especially when it appears simple (and nothing could be as dangerous as trying to do good to others)

FellippeHeitor

  • Guest
Re: UEVENT alternative
« Reply #1 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)

Offline krovit

  • Forum Regular
  • Posts: 179
    • View Profile
Re: UEVENT alternative
« Reply #2 on: February 04, 2020, 05:09:06 am »
Thanks Filippe, Thanks, I will try to implement this function that I already use elsewhere.
Nothing is easy, especially when it appears simple (and nothing could be as dangerous as trying to do good to others)

Offline TempodiBasic

  • Forum Resident
  • Posts: 1792
    • View Profile
Re: UEVENT alternative
« Reply #3 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
Programming isn't difficult, only it's  consuming time and coffee

Offline krovit

  • Forum Regular
  • Posts: 179
    • View Profile
Re: UEVENT alternative
« Reply #4 on: February 08, 2020, 04:15:38 am »
2 cents interesting... thank you
Nothing is easy, especially when it appears simple (and nothing could be as dangerous as trying to do good to others)