LB Booster
« Using TIMER with a SUB handler »

Welcome Guest. Please Login or Register.
Apr 1st, 2018, 03:49am



ATTENTION MEMBERS: Conforums will be closing it doors and discontinuing its service on April 15, 2018.
We apologize Conforums does not have any export functions to migrate data.
Ad-Free has been deactivated. Outstanding Ad-Free credits will be reimbursed to respective payment methods.

Thank you Conforums members.
Speed up Liberty BASIC programs by up to ten times!
Compile Liberty BASIC programs to compact, standalone executables!
Overcome many of Liberty BASIC's bugs and limitations!
LB Booster Resources
LB Booster documentation
LB Booster Home Page
LB Booster technical Wiki
Just BASIC forum
BBC BASIC Home Page
Liberty BASIC forum (the original)

« Previous Topic | Next Topic »
Pages: 1  Notify Send Topic Print
 thread  Author  Topic: Using TIMER with a SUB handler  (Read 538 times)
Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Using TIMER with a SUB handler
« Thread started on: Mar 27th, 2015, 6:22pm »

There's currently a thread at the LB Community Forum with the subject 'timer 0' not working which describes a problem arising from the use of the TIMER statement. In LB 4.04 the only kind of timer handler you are allowed is a [label], which means that if the timer fires when the label is 'out of scope' (typically when a SCAN or WAIT is executed inside a SUB or FUNCTION) a run-time error will result.

As the OP found, this issue can be difficult to work around; he resorted to disabling the timer with TIMER 0 before calling the subroutine and re-enabling it afterwards, but still experienced problems. One of the responses posted there was "I personally do not use the Timer function in LB as it seems to cause more issues than I care for".

In LBB you can alternatively specify a SUB as the handler in the TIMER statement (if you try that in LB4 it crashes). The potential advantage of using a SUB handler is that it is always in scope, so whether the timer fires in the 'main program' or when inside a function it should always work correctly.

Richard.
User IP Logged

CryptoMan
New Member
Image


member is offline

Avatar




PM

Gender: Male
Posts: 46
xx Re: Using TIMER with a SUB handler
« Reply #1 on: Mar 28th, 2015, 10:54pm »

In Unix with C we were using SETJMP and LNGJMP for this with ALARM function to fire a timer alarm and then jump to function from wherever we are and then after handling whatever necessary we made a long jump back into the where this timer event was triggered.

So, effectively LBB is able to this powerful thing.

Would it be possible to handle multiple timers?

Can we trap and handle other signals?
User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx Re: Using TIMER with a SUB handler
« Reply #2 on: Mar 28th, 2015, 11:12pm »

on Mar 28th, 2015, 10:54pm, CryptoMan wrote:
Would it be possible to handle multiple timers?

This LB demo of multiple timers works fine in LBB too:

http://lbpe.wikispaces.com/MultipleTimerRoutines

Richard.
User IP Logged

Pages: 1  Notify Send Topic Print
« Previous Topic | Next Topic »

| |

This forum powered for FREE by Conforums ©
Terms of Service | Privacy Policy | Conforums Support | Parental Controls