SmartCAM Technical Bulletin: 209
Announcing

Topic: Passing variables to the Code Generator

Technote 209
Date: 05/05
Product: All
Version: All

Problem:
How do I use variables defined in the application in the Code Generator?

Solution:
Pre-allocated words, or system variables are passed automatically. See the Template Word Reference topic in the Learning SmartCAM documentation for information about Pre-allocated User Words.

The value of a macro user variable can be retrieved from within the Code Generator through the system calculator. In any sort of equation, if the Code Generator can't find a macro variable within its own variable set, it invokes the system calculator which tries to find it elsewhere. The primary function in the Code Generator where this happens is the #EVAL() statement.

For example:

@DECLARE
#INT #codeType

@START
#EVAL(#codeType=#yourVariableHere)

Then you can use #codeType inside the Code Generator wherever you need to.

Be aware not to name your Code Generator variable the same as your macro user variable because then the Code Generator will find the Code Generator variable first and never invoke the calculator to look in the macro system.

Generally variables are used in a macro, but can also be accessed from other places. They can reside in the JOS subsystem with Data Tags (see the Customizing format files - Job Operations Setup data tags topic in the Customization Guide), User Commands can contain them (see User Event in Help) and they can be entered directly.

You can enter variables or expressions in most input fields of the SmartCAM interface. Variable names '#myVar', JOS Data Tags 'JOS(tl_dia)', and Snap Commands 'STX(#el)' are all acceptable inputs. When recording a macro, the variable name or expression is recorded, not the value. This is useful for creating similar parts with variable dimensions for example.