Defines a macro name and the text to substitute for it during compilation. There are two forms of macros in ASPECT.
Simple text substitution:
#define name text
name The macro name to be defined.
text The text to be substituted for the macro name when processed by the ASPECT Compiler.
Argument/text substitution:
#define name([name[,name]...]) text
name The macro name to be defined.
([name[,name]...]) Zero or more arguments to be processed by the compiler with the substitution text.
text The text to be substituted for the macro name when processed by the ASPECT Compiler.
Example
#define TRUE 1 ; Constant to use in place of TRUE.
#define FALSE 0 ; Constant to use in place of FALSE.
proc main
integer Error ; Integer to contain Error.
Error = TRUE ; Set error to true, or 1.
if Error == TRUE ; Check to see if error is true
usermsg "True" ; or false and display message.
elseif Error == FALSE
usermsg "False"
endif
endproc
; #define macro(arglist)
; The statement below declares a macro that calls the internal
; SDLGMSGBOX function to display the specified message.
; Each operand, "a", "b", "c" corresponds to a parameter in the
; SDLGMSGBOX function.
#define PutMsg( a,b,c ) sdlgmsgbox a b STOP OK c 1
proc main
string Title, BoxText ; Strings for title and text.
integer Choice ; Integer for button selection.
Title = "Macro Example" ; Assign value to title and text.
BoxText = "This is an example of Macro Expansion."
; Call internal SDLGMSGBOX function using macro.
PutMsg( Title, BoxText, Choice )
endproc
Comments
Similar to macros in the "C" programming language, #define allows for textual substitution within a source program.
If the argument/text substitution macro form is used, any arguments specified must follow the standard ASPECT naming convention in the #define statement.
In this case, I've assigned the element array[0] the label foo. I then set foo to be "testing!", then print the value of array[0] (i.e. what foo points to), and get the expected value.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.