|
Post by Stefan on Jul 29, 2021 10:57:16 GMT -5
I noticed that thinBasic supports the use of a colon ( : ) to separate statements on a single line, although I haven't been able to find official confirmation of this on the thinBasic pages.
e.g.
myVar1 = 23 : myVar2 = 25 is equivalent to myVar1 = 23 myVar2 = 25
Hence I was tempted to improve readability of this code sequence:
SELECT CASE occ$ CASE "NEXT" : occ$ = "FIRST"
CASE "PREV" : occ$ = "LAST" CASE "FIRST","LAST" : RETURN item$+" not found" END SELECT
(The section was within a loop which, having failed to find item$ on the first attempt, retries the search against the whole file.) BUT... while the switch from NEXT to FIRST or PREV to LAST worked perfectly, and occ$ had the correct values at all times, the RETURN statement was never executed.
Turns out that the colon separator does not work if the CASE statement presents a list (as in "FIRST", "LAST"). In this case
SELECT CASE occ$ CASE "NEXT" : occ$ = "FIRST" CASE "PREV" : occ$ = "LAST"
CASE "FIRST","LAST"
RETURN item$+" not found" END SELECTworks fine.
Took a fair while to figure out the weird results I was seeing.
Serves me right for bringing REXX principles to a thinBASIC party, I guess!
|
|
|
Post by George on Jul 29, 2021 11:54:58 GMT -5
Stefan: Yes, thinBasic does have a few quirks. In it's very early releases I reviewed the parsing code to see how it was handled. Quite tricky code, but Eros is pretty sharp. I imagine as thinBasic has grown it's only gotten more convoluted internally.
George
|
|
|
Post by George on Jul 29, 2021 13:20:56 GMT -5
Robert: I tried it as well with the 1.11 Beta release, still doesn't work.
I posted the problem in the thinBasic support forum.
George
|
|
|
Post by George on Aug 3, 2021 8:18:26 GMT -5
Got a repoly from one of the thinBasic MVP support stuff.
Basically it says
"if it hurts, don't do it" i.e. don't use the CASE xx: action, separate them on multiple lines.
George
|
|
|
Post by George on Aug 4, 2021 9:13:40 GMT -5
Robert: Maybe you can do that when you do the macros reorganization.
George
|
|
|
Post by erosolmi on Aug 25, 2022 2:52:09 GMT -5
Hi all,
I just saw this thread, sorry to be so late.
This is a thinBasic problem. Also there is a bug in CASE statement followed by a list of values regardless of colon usage. I will try to fix for the next update. Will consider : just like a new line token, should work.
Will let you know Eros
|
|
|
Post by erosolmi on Aug 26, 2022 3:05:53 GMT -5
|
|