I know that it's been thought about before -- how to have separate groups of DATA statements for different purposes?
Well, it came to me today and it didn't involve changing anything in BCX.
The macro READ() in the code below will read the strings in whichever context it is used in.
That means, if you have a string array named "DATA" in one or more SUBS or FUNCTIONS, it
grabs the data from within the SUB or FUNCTION that is executing. Otherwise, it will grab strings
from the GLOBAL string array named "DATA", if there is one. It's all about scope.
So, save the code below to a file, translate, compile, and run it.
If you're like me, you will probably think, "That's pretty damn cool!"
CONST READ(a)=DATA[(a)-1] ' Handy little macro -- will probably be added to BCX
PRINT OneFoo$ (2) ' Read LOCAL DATA
PRINT TwoFoo$ (5) ' Read Different LOCAL DATA
PRINT READ$ (4) ' READ GLOBAL DATA (below) .... Using our macro
DATA Ford, Chevy, Buick, Oldsmobile '<<< GLOBAL data
FUNCTION OneFoo$ (item)
'*******************
SET DATA$ [] ' Must come before any reference is made to it
"one",
"two",
"three"
END SET
'*******************
LOCAL A$
A$ = READ$(item) ' Using our macro
FUNCTION = A$
END FUNCTION
FUNCTION TwoFoo$ (item)
'*******************
SET DATA$ [] ' Must come before any reference is made to it
"apples",
"oranges",
"bananas",
"grapes",
"melons"
END SET
'*******************
LOCAL A$
A$ = READ$(item) ' Using our macro
FUNCTION = A$
END FUNCTION
OUTPUT:
two
melons
Oldsmobile