In a message dated 19/10/2003 14:00:33 GMT Standard Time, [EMAIL PROTECTED] writes:
It seems a wonderful facility. Something like: Digging out my SBASIC/SuperBASIC Reference Manual throws some light on the
WHEN condition
statement.... (or at least I tried to work out when and how it worked)
Although the structure is provided in JS or later ROMs (including Minerva) and even the THOR XVI, it is not present in SMSQ/e. It is also highly unreliable unless you have Minerva 1.77 or later (although Toolkit II does improve it slightly). Problems, unless you have v1.77 Minerva or later:
- Block called more than once
- May report bad name when the block is called (ie the condition is true)
- The interpreter allows the WHEN to remain in force despite NEW, CLEAR, LRUN, LOAD, MERGE and MRUN, unless you have Toolkit II.
- JS and THOR XVI only allow a max. 20 WHEN clauses
The condition can be anything allowed by an IF statement PROVIDED that it begins with a variable, for example
WHEN a-10=b is fine
WHEN 10-a=b is not
You also have to be careful, as WHEN is not iterative - ie. if the code contained in the WHEN... END WHEN structure alters a variable which sets the condition true again, then the WHEN block is not called a second time.
There is also a big problem, in that if the variables used in the condition test are not defined when the interpreter first needs to test the condition - an error in _expression_ is reported - for example:
4 WHEN x>1 AND y>1
5 x=x+1:PRINT 'X and Y are greater than 1'
6 END WHEN
10 PRINT "start"
100 FOR x=1 TO 2
110 FOR y=1 TO 2
120 PRINT !x,y!
130 END FOR y
140 END FOR x
You get an error in _expression_ when the program reaches line 100 - the interpreter realises that it needs to test x, but does not know what y is. To solve this, add:
1 y=0
The other main problem is that if you make up several WHEN clauses, which test the same variable for different conditions, if the conditions overlap, there is no guarantee which WHEN clause will be executed !!
As suggested by Dilwyn, if the WHEN clause is executed (condition is true), once END WHEN is reached, the program will continue from where it was before calling the WHEN clause. There is no way of validly exiting a WHEN clause.
--
Rich Mellor RWAP Services 35 Chantry Croft, Kinsley, Pontefract, West Yorkshire, WF9 5JH TEL: 01977 610509 Visit our website at: URL:http://www.rwapsoftware.co.uk In need of adventure? URL: http://www.rwapadventures.com Stuck with ordinary dial up internet connection ?? Read our review of internet accelerators and broadband at: URL:http://www.rwapservices.co.uk |
- Re: [ql-users] wm.rptrt P Witte
- Re: [ql-users] wm.rptrt wlenerz
- Re: [ql-users] wm.rptrt P Witte
- Re: [ql-users] wm.rptrt wlenerz
- Re: [ql-users] wm.rptrt P Witte
- Re: [ql-users] wm.rptrt Jerome Grimbert
- Re: [ql-users] wm.rptrt Marcel Kilgus
- Re: [ql-users] wm.rptrt P Witte
- Re: [ql-users] wm.rptrt thegilpins
- Re: [ql-users] wm.rptrt P Witte
- RWAPSoftware