Author |
Topic: LBB Macro capability (Read 89 times) |
|
k6dgw
New Member
member is offline
Gender:
Posts: 6
|
|
LBB Macro capability
« Thread started on: Mar 14th, 2018, 10:07pm » |
|
Does LBB have a macro capability like the "define" statement often placed in header files in C? Hypothetical example:
define NROWS=100 define NCOLS=7
dim datarec(NCOLS, NROWS)
for i=1 to NROWS for j=1 to NCOLS blah blah blah next j next i
Tks,
Fred
|
|
Logged
|
Fred Sparks NV USA
|
|
|
RobM
Junior Member
member is offline
Posts: 91
|
|
Re: LBB Macro capability
« Reply #1 on: Mar 15th, 2018, 04:20am » |
|
I'm not sure if it is the same idea but there is the "Let" command.
Code:
Let NROWS=100
Let NCOLS=7
dim datarec(NCOLS, NROWS)
for i=1 to NROWS
for j=1 to NCOLS
blah
blah
blah
next j
next i
|
« Last Edit: Mar 15th, 2018, 04:20am by RobM » |
Logged
|
|
|
|
Richard Russell
Administrator
member is offline
Posts: 1348
|
|
Re: LBB Macro capability
« Reply #2 on: Mar 15th, 2018, 09:53am » |
|
on Mar 14th, 2018, 10:07pm, k6dgw wrote:Does LBB have a macro capability like the "define" statement often placed in header files in C? |
|
Not as such. The example you gave is not of a macro but of a constant declaration (#define can be used for both purposes).
Most BASICs (Liberty BASIC is no exception) don't have named constants, and variables must be used instead. You can adopt a naming convention (I tend to use all CAPITALS for constants) to remind you that the variable actually represents a constant and should not be altered - but unlike a true constant there's nothing stopping you.
Variables used this way will generally need to be GLOBAL, of course, so the closest approximation in LB/LBB to #define, when used to declare a constant, is:
Code: global NROWS, NCOLS
NROWS = 100
NCOLS = 7 Macros are another issue however; Liberty BASIC has no real equivalent to macros. In some limited circumstances you may be able to leverage the EVAL function to give a similar effect, but this is not ideal.
Richard.
|
|
Logged
|
|
|
|
k6dgw
New Member
member is offline
Gender:
Posts: 6
|
|
Re: LBB Macro capability
« Reply #3 on: Mar 15th, 2018, 4:44pm » |
|
OK. I'll have to rethink some plans, but I think I can make this work. Thanks
|
|
Logged
|
Fred Sparks NV USA
|
|
|
|