LB Booster
« LBB Macro capability »

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



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: LBB Macro capability  (Read 93 times)
k6dgw
New Member
Image


member is offline

Avatar




PM

Gender: Male
Posts: 6
xx 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
User IP Logged

Fred
Sparks NV USA
RobM
Junior Member
ImageImage


member is offline

Avatar




PM


Posts: 91
xx 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 » User IP Logged

Richard Russell
Administrator
ImageImageImageImageImage


member is offline

Avatar




Homepage PM


Posts: 1348
xx 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.
User IP Logged

k6dgw
New Member
Image


member is offline

Avatar




PM

Gender: Male
Posts: 6
xx 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
User IP Logged

Fred
Sparks NV USA
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