### Passing Variables To and From BASIC Scripts

From PC-DMIS code, variables can only be passed to BASIC scripts, not from BASIC scripts.

The only supported variable types that can be passed into BASIC scripts from PC-DMIS are:

- Integer

- String

- Double

Variables are passed as comma separated values (known as arguments). These are defined in the FUNCTION/ statement within the SCRIPT/FILENAME code block. The FUNCTION/ statement specifies not only the arguments but also the subroutine within the script that will take the passed values. By default this line initially reads

FUNCTION/Main,SHOW=YES,,

This means the subroutine named "Main" will take the arguments. SHOW=YES simply shows or hides the closing ENDSCRIPT/ statement for the command block.

Notice the two commas following SHOW=YES above. These indicate a field where you may define your first argument. Simply type the value in the field and press TAB. PC-DMIS automatically adds "ARG1=" before the first value to indicate that it's the first argument. And an additional comma is also added to allow for additional arguments. Any additional arguments will have "ARG2=" and "ARG3=" and so on added as prefixes once values are defined therein.

Consider the examples below.

Note: PC-DMIS variables only hold values during part program execution; at learn time, PC-DMIS variables will always have a value of zero.

More:

Example 1: Using the Function Line to Pass Variables

Example 2: Using the GetVariableValueand SetVariableValueMethods to Pass Variables