Danfoss MCO 305 Design Manual page 173

Programmable motion controller
Hide thumbs Also See for MCO 305:
Table of Contents

Advertisement

MCO 305 Design Guide
__ How to Program __
All instances of "name" that follow this statement will be replaced with "string". Note that "string" will
contain all characters (including spaces) up to the end of the line. The line may be continued using the "\"
line continuation character if necessary.
Definitions can be cleared again using the following statement:
#undef name
The following names are predefined:
__DATE__ - The date when the program was compiled (as a character string).
__TIME__ - The time when the program was compiled (as a character string).
__FILE__ - The filename of the program (as a character string).
__LINE__ - The current line number in the program (as a number).
Example:
#define ARRAY_LEN 100
#define PRINT_MSG print " apos = ",apos," avel = ",avel
DIM prm[ARRAY_LEN]
PRINT_MSG
PRINT "This is line ",__LINE__
is the same as:
DIM prm[100]
PRINT " apos = ",apos," avel = ",avel
PRINT "This is line ",5
Text replacement is done recursively. Once the original string has been replaced, then the Preprocessor will
look for other replacements within the new string. Note that text replacement is not done within the
#define statement itself and is not done within strings enclosed in quotes.
Example:
#define VALUE 10
#define PRINT_MSG print "VALUE = ",VALUE
PRINT_MSG
#define VALUE 20
PRINT_MSG
is the same as:
PRINT "VALUE = ",10
PRINT "VALUE = ",20
Defines may also include one or more arguments separated by commas as follows:
#define name(arg1,arg2) string
In this case, instances of "arg" will be replaced in "string".
Example:
#define SQUARE(x) ((x)*(x))
#define SUM_SQUARE(x,y) (SQUARE(x) + SQUARE(y))
i = SUM_SQUARE(3,4)
i = SUM_SQUARE(a,b)
is the same as:
i = (((3)*(3)) + ((4)*(4)))
i = (((a)*(a)) + ((b)*(b)))
173
®
MG.33.L5.02 – VLT
is a registered Danfoss trademark

Hide quick links:

Advertisement

Table of Contents
loading

Table of Contents