# Use of Normal and [] type of Variables

• Hallo all,

When we are using []- square brackets by a variable it means this is an Array. I see in Byte, Integer, Double, Real, Position, String a square brackets Option, till now the Projects which I saw they are using indvidual elements. Can any one please write a sample Programm where we are using Arrays.

• The [] notation is not strictly speaking an array, it's more accurately an indirect reference. So if you write something like P[B000], and the value of B000 is 10, then the resulting variable address becomes P010. If at some later point you change B000 to 20 and reference P[B000] again, the actual address referenced becomes P020. This is useful if you have a set of preprogrammed position variables for say, part A, and another set of preprogrammed position variables for part B. You can use the same inform code to handle the motion, just alter your index (what's inside the []) depending on your part number. See a very simplistic example, that may not be perfect syntax, but demonstrates the principle:

' SET UP INDEX VARIABLES DEPENDING ON PART NUMBER (B000)
IF B000=1 THEN
SET B001=10
SET B002=11
SET B003=12
SET B004=13
ELSEIF B000=2 THEN
SET B001=20
SET B002=21
SET B003=22
SET B004=23
ENDIF

MOVJ P[B001]
MOVJ P[B002]
MOVJ P[B003]
MOVJ P[B004]

The code above assumes that P010-013 and P020-024 contain valid position data, and that B000 is either 1 or 2.

Scott