Creating variables



Viewing variables

Select the Variables option from the Edit menu to see a list of variables that have been defined in a flowchart. New variables can be defined using the Add New Variable button.

Variables can be deleted provided that they are not used by any icons within a flowchart. Flowcode will warn of this condition.


Creating variables

Enter the variable name including any array size details.

Variables can be a maximum of 32 alphanumeric characters. They can contain underscore ( _ ) characters but not spaces. At least one letter must be included in the variable name to distinguish it from a pure number.


Select the variable type for the new variable.


Note that variable names "retain" their capitalization, but Flowcode itself it not case sensitive.  If a variable is created as "MyVar", then it will be shown as "MyVar" throughout the document.  Note that the variable name is changed to "FCV_MYVAR" in the actual C code, as c code is case sensitive.


Variable types

Variables can be specified as one of the following types:


Type                Range                        Bit Depth

BYTE                0-255                        8-bit unsigned variable

INT                -32768 to 32767                16-bit signed variable

String                0-255                        8-bit unsigned array. Default size is 20.

Floating point        -Inf to +Inf                32-bit signed variable


Numeric values can be in decimal (unmarked) or in HEX format (preceded by 0x) or in Binary format (preceded by 0b)


e.g. 255 or 0xFF or 0b11111111.


Strings are an array of ASCII characters.

An ASCII character is a BYTE variable corresponding to the ASCII value of the appropriate character.

If no array size is specified the default size of [20] characters is automatically assigned.


Arrays

Arrays can be created by adding an array size attribute in square braces to the variable name. E.g. MY_ARRAY[10] creates an array called MY_ARRAY with 10 members in the array.


You can set the value of an array member in a calculation icon by using the array name with the member number in square braces. E.g.MY_ARRAY[3] = 32.

Note that Arrays start at 0 i.e. an Array with 10 members will use 0-9 as the member numbers.


You can modify the array size by selecting the array in the list and clicking on the Array size button.

You can only edit the size attribute not rename the variable.


The only difference between an array of bytes and a string is that the string variable is available for use with the Flowcode string manipulation functions. In C code the two are identical.