ID : 3522
Macro Definition
Macro refers to replacement of macro name in a code right before compilation.
There are macros defined by users and "embedded macros" defined in PacScript.
Macros defined by users are defined using #Define and specifies a code to replace with a macro name.
#Define HOME P[50] 'P[50] is renamed as "HOME"
TakeArm
Move P, HOME 'Return to the home position
'Various processing
Move P, HOME 'Return to the home position
In the above example, a position P[50] is defined as "HOME" and such definition is described in the program code. To change this position variable to J[10], just change the line defined by #Define and then all "HOME" specifications are conveniently changed.
Macros are processed in the preprocessor process right before compilation. A defined "macro name" is replaced by a designated "code to replace."
There are "constant macros" and "functional macros."
- Constant macro
- A defined "macro name" is replaced by a designated "code to replace." Especially, those to be replaced literally may be called macro constants.
- Functional macro
- A defined "macro name" and argument are replaced.
Functional Macro
A functional macro replaces a defined "macro name" and argument.
#Define DAIKEI(top,bottom,height) (top + bottom) * height / 2
PrintDbg "Area of trapezoid is " & DAIKEI(5,10,4) & ""
ID : 3522
- Related Information
- Embedded Macro