This simple example will execute wait_alarm every two seconds.
Code: Select all
Declare Function Signal cdecl alias "signal" (ByVal V_Signal As long, byval V_Function As Any Ptr) as Any Ptr
declare function alarm cdecl alias "alarm" (byval __seconds as uinteger) as uinteger
#if defined(__FB_WIN32__)
const SIGALRM=14
#elseif defined(__FB_DOS__)
const SIGALRM=293
#elseif defined(__FB_LINUX__)
const SIGALRM=14
#endif
sub wait_alarm(isignal as integer)
?"This is the scheduled event"
alarm(2) 'loads another alarm events: each alarm event is a single time event, so to repeat it it must be set again every time
end sub
signal(SIGALRM, @wait_alarm)
alarm(2) 'the alarm event is triggered after 2 seconds
for i as integer=1 to 10
?i
sleep 1000
next