Common Syntax Errors
There is a small set of SmartCAM macro errors that users are likely to encounter, especially when updating older macros. The following list outlines common macro syntax errors and offers suggestions on how to resolve them.
Global Variable System
All simple data variables in SmartCAM are global variables. Once declared, they will remain in effect and continue to be valid until they are either removed or the application is restarted. This means a variable declared as a specific type in one macro is being redefined as a different type in a different macro (if both macros use the same variable name).
This is covered in the Fundamental : Variables Scope topic.
The Macro Variables dialog, accessible from Macro - Variables, can also be
used to check which variables are set, their data types, and their current contents.
This only applies to simple data variables: INTEGER, DECIMAL, and STRING. Arrays are transitory constructions and only exist while the macro is running. When a macro ends, they are removed. Even so, a previous macro has defined a simple data variable with the same name as the array variable in the current macro. This could cause problems or false syntax errors.
To reduce the chances of one macro inadvertently affecting another, it is suggested that all variable names be prefaced with a unique suffix. The suffix should be related to the macro or custom Panel they are associated with. For example, the Path Length macro could have prefaced all variables with "PL_".
The suffix helps reduce the chance of the same variable name being used in multiple macros. It also helps keep variables grouped in the Macro Variables dialog.
Keep in mind the suffix uses some of the 12 available variable name characters. So, do not make the suffix too long.
Custom PCB Panels
Variables declared on a custom PCB panel are instantiated when the panel is displayed. They do not need to be redeclared in the macro file itself.
When using Macro - Execute - Check Macro to verify a macro that is launched by a custom panel, first navigate to the panel and display it. This will create the necessary variables and add them to the Global Variable System. Then, when the macro is checked, the correct variables will exist.
Common Macro Errors
3079: Malformed DATA statement
When declaring a new variable, the declaration statement in the macro file is incorrectly written. The DATA string is replaced with the actual data type: INTEGER, DECIMAL, or STRING.
Example: INTEGER:#A A
This example triggers the error because "#A A" is not a valid declaration or variable name.
3081: Attempted redefinition of the variable <variable name>
This is a variable scoping issue. The macro is attempting to redeclare a variable that has already been established. For example:
INTEGER:#IVAR // variable declared as INTEGER
DECIMAL:#IVAR // attempting to redefine as DECIMAL
The variable was already instantiated as an INTEGER; it cannot then be redefined as a DECIMAL.
The macro compiler will also complain if the macro attempts to declare the same variable more than once, even if the data type is the same. Example:
INTEGER:#IVAR // variable declared as INTEGER
INTEGER:#IVAR // trying to redefine the variable
A variable only needs to be declared once. For these types of errors, check the macro file for multiple declarations of the same variable name. If they are of the same data type, remove the duplicate declarations, keeping the first declaration. If the redeclarations are for different data types, use new variable names for the redeclarations.
Using VAR_REMOVE[] will not resolve this issue. Example:
INTEGER:#IVAR // variable declared as INTEGER
VAR_REMOVE[VN="IVAR"] // removing the #IVAR variable
DECIMAL:#IVAR // redeclaring as DECIMAL. This will not compile.
The declaration issue is caught while the macro is being compiled, not when it is being run.
Therefore, the VAR_REMOVE[] command will be checked for proper syntax but is not executed.
So, #IVAR is still considered to exist and of type INTEGER before and after
the VAR_REMOVE[] command.
Using the same variable name for multiple data types is a very poor idea and can lead to significant downstream confusion and hard-to-trace problems. The SmartCAM MCL compiler is keeping this bad programming technique from being used.
3082: IF statement missing ENDIF
3083: WHILE statement missing ENDW
These two issues are closely related and are therefore grouped together. The
IF conditional branching
block and the WHILE
conditional loop require a macro statement to close the end of the block. The end-of-block statement
is missing.
Find the beginning of the IF or WHILE block on the line provided in the error.
Then, trace through the code until the end of the statement block is found. Add the missing
ENDIF or ENDW statement.
3085: Label already defined <label name>
The macro command GOTO()
jumps to a specific label in the macro. Each label must be unique; otherwise, the macro engine will not know
where to branch to.
This error is triggered when the same label name is used more than once. Example:
@LABEL1
... macro code
GOTO(LABEL1)
... macro code
@LABEL1
In this example, the label "LABEL1" is defined twice. Remove one of the two labels or rename one of them.
3086: Reference to undeclared label <label name>
Similar to error 3085, in this instance, the
GOTO() label
is missing. Example:
GOTO(LABEL1)
... macro code
The branch location LABEL1 is not defined in the macro file; the GOTO()
command has no place to branch to.
Locate the code section where the GOTO should jump to and add the corresponding label. Otherwise, remove the unnecessary GOTO() command.
3087: Reference to undefined function <function>
The function being called is not a valid function name. Example:
#D=TOTLE() // use TOTEL() to get the total # of elements
In this case, the macro function TOTEL() is misspelled. Refer to the Automation/Customization -
MCL Reference section of Learning SmartCAM for a complete list of valid macro functions and commands.
3088: No function having the signature <function signature>
A function signature is a
description of the data types, number, and order of function parameters and return value. The referenced
macro function does not match this signature.
For example, the function signature for the TYP() function is INTEGER TYP(INTEGER).
This means the single parameter is an INTEGER, and the return value is an INTEGER. Therefore, the following
will generate this error:
INTEGER:#RETVAL
STRING:#ELMT="1"
#RETVAL=TYP(#ELMT)
There is no function signature for INTEGER TYP(STRING), which is what the example macro is
using, so an error is displayed.
3097: The variable name <variable name> exceeds the maximum number of characters.
The given variable name is too long. Reduce the size to 12 characters or fewer. Ensure that you update the variable name in all instances where it is used.
3099: Unreferenced label <label name>
A label is used as part of an unconditional branch
and takes the form of "@LABEL_NAME." All labels must be referenced by a GOTO()
command. Those that are not should be commented out or deleted.
3100: Use of a deprecated function signature <function signature>
A function signature
is a description of the data types, number, and order of function parameters and return value.
A deprecated function signature is an older function signature that is being superseded or replaced. Many
macro commands that now require a given parameter to be an INTEGER previously allowed the parameter
to be a NUMBER. Where a NUMBER was either a decimal or integer.
In most cases, this did not make sense. For example, what is element number 1.75?
Refer to the Automation/Customization - MCL Reference - Reference: Macro Commands and Reference: Macro Functions topics for a complete list of macro commands and functions. Update the macro parameters to match the current function signature.
3101: Reference to an undefined macro parameter <parameter>
As SmartCAM evolves, the parameters to existing macro commands may change. This error shows a parameter that is no longer used by the associated macro command.
Generally, these can be deleted without incident.
It is a good idea to look up the macro command or function in the Automation/Customization - MCL Reference - Reference: Macro Commands and Reference: Macro Functions topics to see what the current set of parameters is and what each does.
3102: Unsupported mixed-type assignment to "variable"
The macro is attempting to assign the wrong type of data to a macro variable; for example, assigning a string to an INTEGER or DECIMAL variable or a decimal to an INTEGER variable.
Another common cause is assigning text to a string without enclosing the text in quotes. Example:
STRING:#SVAR
#SVAR=Testing One Two Three // this will cause an error, the quotes are missing
#SVAR="Testing One Two Three" // this will work
Ensure that strings are quoted and have both leading and trailing quotation marks.
Related Topics