Variables / Registers / Arrays #V

Command group to execute calculations and logical operations. With the help of the string files, internationalization (multiple languages) can be realized. There are registers for numbers and strings (can record characters up to 200), integer registers use signed 32-bit, floating-point registers use 23-bit mantissa, 8-bit exponent, 1-bit signed.


String file / multilingualism

Load string file

(Variable stringFile Load)

#VFL

<StringfileName>

Delete string file

(Variable stringFile Delete)

#VFD

<StringfileName> (all)

Send number of loaded string files

(Variable stringFile Count)

#VFC


String register

Set string register

(Variable Stringregister Set)

#VSS

String-ID, "String"; "String" [ID+1]; ...

Set string register from position

(Variable Stringregister Postion)

#VSP

String-ID, Offset, "New String";

Replace string register from position

(Variable Stringregister Replace)

#VSR

String-ID, Offset, "New String";

Cut out and replace sub-string from string register

(Variable Stringregister Truncate)

#VST

String-ID, Offset, Number(until end)

Copy sub-string from string register

(Variable Stringregister Copy)

#VSC

String-ID Target, String-ID Source, Offset (0), Number(until end)

split string registers in sub-strings

(Variable Stringregister dElimiter)

#VSE

String-ID Target Start, String-ID Source, Seperator, Register-ID (=String-ID Target Start)

Set string register with date/time

(Variable Stringregister Date)

#VSD

String-ID, "Dateformat"; date (act. time); 1/100sec

Set formatted string register

(Variable Stringregister Formated)

#VSF

String-ID, "Formatted string"; Value, Value2, ...., ValueN

Read object strings

(Variable Stringregister Object)

#VSO

String-ID, Obj-ID, ...

Send string register (ASCII)

(Variable string Send Ascii)

#VSA

String-ID, ...

Send string register (Unicode)

(Variable string Send Unicode)

#VSU

String-ID, ...

Sort string register

(Variable Quicksort Strings)

#VQS

String-ID Start, String-ID End, Number (0), Offset(0)

Sort codes in string register

(Variable Quicksort Codes)

#VQC

String-ID, Direction (1), Number (0), Offset (0)

Last error message in string register

(Variable Stringregister Last error)

#VSL

String-ID, Delete(1)

Mix string register

(Variable Mix Strings)

#VMS

String-ID Start, String-ID End

Mix codes in string register

(Variable Mix Codes)

#VMC

String-ID, Number (0), Offset (0)

Define regular expression

(Variable String regular eXpression)

#VSX

RegEx-ID, "regular expression"

Observe string register

(Variable Observe StringRegister)

#VOS

String-ID, "String" [ID+1]; ...

Delete Changeflag of string register

(Variable Delete StringRegister Changeflag)

#VDS

String-ID

Read WIFI SSID to string register

(Variable Stringregister WIFI)

#VSW

String-ID

Read mDNS name to string register

(Variable Stringresgister Name)

#VSN

String-ID, PLC address

Register

Set register (integer)

(Variable Register Integer)

#VRI

Register-ID, Value, Value1 [ID+1], ...

Set register (float)

(Variable Register Float)

#VRF

Register-ID, Value, Value1 [ID+1], ...

Convert object string

(Variable Register Object)

#VRO

Register-ID, Obj-ID, Obj-ID1[ID+1], ...

Convert string register to register

(Variable Register dElimiter)

#VRE

Register-ID Start, String-ID Source, Seperator, Register-ID Name

Write register to RTC-RAM

(Variable Register rtc Write)

#VRW

ID, Register-ID, Register-ID1, ...

Read register from RTC-RAM

(Variable Register rtc Read)

#VRR

ID, Register-ID, Register-ID1, ...

Convert string register as calculation to register (integer)

(Variable Calculate Integer)

#VCI

Register-ID, String-ID, String-ID1[ID+1], ...

Convert string register as calculation to register (float)

(Variable Calculate Float)

#VCF

Register-ID, String-ID, String-ID1[ID+1], ...

Send register

(Variable Register Send)

#VRG

Register-ID, ...

Sort register

(Variable Quicksort Register)

#VQR

Register-ID Start, Register-ID End

Mix register

(Variable Mix Register)

#VMR

Register-ID Start, Register-ID End

Observe register

(Variable Observe Register)

#VOR

Register-ID, "Register" [ID+1]; ...

Delete Changeflag of register

(Variable Delete Register Changeflag)

#VDR

Register-ID

Assign a register to an analogue channel

(Variable Register Analog)

#VRA

Register-ID, Channel

Assign a register to an I/O Port channel

(Variable Register Port)

#VRP

Register-ID, Port

Array

Define array (Integer)

(Variable Array Integer)

#VAI

Array-ID, Number, Type(0)

Define array (Float)

(Variable Array Float)

#VAF

Array-ID, Number, Type(0)

Define array (Unicode string)

(Variable Array Unicode)

#VAU

Array-ID, Anzahl, Stringlength, Type(0)

Delete array (free memory)

((Variable Array Delete)

#VAD

Array-ID

Fill array

(Variable Array Set)

#VAS

Array-ID, Value(0, all Elements), element index

Assign values to array elements (with index)

(Variable Array Value)

#VAV

Array-ID, Index, Value, Value[Index+1], ...

Assign values to array elements (with current write pointer)

(Variable Array Write)

#VAW

Array-ID, Value 1, Value 2, ...

Set writing and/or reading pointer

(Variable Array Pointer)

#VAP

Array-ID, WritePointer(-1), ReadPointer(-1), max. WritePointer

Sort array

(Variable Quicksort Arrays)

#VQA

Array-ID, StartIndex, EndIndex(last Index), Stringlength(0), Stringoffest(0)

Mix array

(Variable Mix Arrays)

#VMA

Array-ID, StartIndex, EndIndex(last Index)

Observe array

(Variable Observe Array)

#VOA

Array-ID, "Array" [ID+1]; ...

Delete Changeflag of array

(Variable Delete Array Changeflag)

#VDA

Array-ID


String file / multilingualism

"Hello World" is placed in 4 different languages. It must be ensured that the selected font supports all necessary characters. In the following example "Arial Unicode MS" was used. The commands below assume that the string files (Chinese.txt, English.txt, Cyrillic.txt and German.txt) are already available on FLASH in the project path in the string's subfolder:

...

#VFL <P:string/German.txt>  

#SSP 1,1,10,10,7,!HELLO!;

#VFD  

#VFL <P:string/English.txt>  

#SSP 2,1,10,50,7,!HELLO!;

#VFD                      

#VFL <P:string/Cyrillic.txt>  

#SSP 3,1,10,90,7,!HELLO!;

#VFD  

#VFL <P:string/Chinese.txt>  

#SSP 4,1,10,130,7,!HELLO!;

#VFD  

...


Load string file

#VFL

<StringfileName>

Load a set of strings. A maximum of 1000 strings from 8 different files can be loaded at the same time.


Delete string file

#VFD

<StringfileName> (alle)

Delete a set of strings or all. The files are physically retained on the SD card so that they can be reloaded.


Send number of loaded strings

#VFC

Places the number of loaded strings in the send buffer. The feedback is structured as follows:

ESC

V

F

C

Number

...


$1B

$56

$53

$43

16-Bit value

...

#VFL ...

#VFL ...

#VFL ...

#VFL ...

#VFC

...

String register

Set string register

#VSS

String-ID, "String"; "String" [ID+1]; ...

The command saves the String in the register set (String ID [0 ... 199]).

String-ID

Value

0

"Hello World"

1

"Test Hello World"

2

"Hello World Test"

...

#VSS 0,"Hello World";"Test "S0;S0" Test";

...


Set string register from position

#VSP

String-ID, Offset, "New String";

The string of the location String-ID is deleted from the position offset and the new data ("New String") are added.

String-ID

Value

0

"Hello Test"

1

...

2

...

...

#VSS 0,"Hello World";

#VSP 0,6,"Test";

...

Replace string register from position

#VSR

String-ID, Offset, "New String";

The string of the location String-ID is replaced with the new data (("New String") from the position offset.

String-ID

Value

0

"Hello Test "

1

...

2

...

...

#VSS 0,"Hello World";

#VSR 0,6,"Test ";

...


Cut out and replace sub-string from string register

#VST

String-ID, Offset, Count(until end)

Delete the "left" part of the string register and move the part from offset to offset + count to the front. If count is negative, count is taken as second offset. It is then an area specification.

String-ID

Value

0

"World"

1

...

2

...

...

#VSS 0,"Hello World";

#VST 0,6,5

...


...

#VSS 0,"Hello World";

#VST 0,6-10

...


Copy sub-string from string register

#VSC

String-ID Target, String-ID Source, Offset (0), Count(until end)

Copy a substring from the string (String-ID Source), starting with the Offset and length Count, and paste it into another string register (String ID Target).

String-ID

Value

0

"Hello World"

1

"World"

2

...

...

#VSS 0,"Hello World";

#VSC 1,0,6,5

...


...

#VSS 0,"Hello World";

#VSC 1,0,6-10

...


Split string register in sub-strings

#VSE

String-ID Target Start, String-ID Source, Seperator, Register-ID (=String-ID Targert Start)

The string (String-ID Source) is split into substrings. The substrings are stored from the String ID Target Start. The number of substrings is stored in the Register-ID. The Seperator parameter specifies the separator.


String-ID

Value

0

"Entry1,Entry2,Entry3"

1

"Entry1"

2

"Entry2"

3

"Entry3"


Register-ID

Value

10

3

...

#VSS 0,"Entry1,Entry2,Entry3";

#VSE 1,0,?,,10

...


Set string register with date/time

#VSD

String-ID, "Dateformat"; date (act. time); 1/100sec

The time is stored in the string register as a formatted string. The presentation is based on the Dateformat. The structure is described in more detail in the sub-chapter Date formats.

String-ID

Value

0

...

1

"14:59:30"

2

...

...

#VSD 1,"%h:%m:%s";

...

Set formatted string register

#VSF

String-ID, "Formatted string"; Value, Value2, ...., ValueN

A formatted string is stored in the string register (String-ID). If the variable set is repeated, the format string is used again and stored in String-ID + 1

String-ID

Value

0

...

1

"Analog 3420"

2

...

...

#VSF 1,"Analog %d";(analog(0))

...


Read object strings

#VSO

String-ID, Obj-ID, ...

Object strings (Obj-ID) are stored in the string register (String-ID). This function is mainly used for EditBoxes.

String-ID

Value

0

...

1

"edit me"

2

...

...

#SED 1,"edit me"     /**Default text for EditBox

#VSO 1,1

...


Sort string register

#VQS

String-ID Start, String-ID End, Number (0), Offset(0)

The area of the string register (String-ID Start to String-ID End) is sorted. Number specifies the area that is considered for the sorting, with number = 0 the entire length is examined. Offset specifies the position in the string where the sorting begins.

String-ID

Value before

Value after

0

"Sort"

"Entry"

1

"Test"

"Exit"

2

"Entry"

"Sort"

3

"Exit"

"Test"

...

#VSS 0,"Sort";"Test";"Entry";"Exit";

#VQS 0,3,2,0

...


Sort codes in string register

#VQC

String-ID, Direction (1), Number (0), Offset (0)

Codes within the string register (String-ID) are sorted. Number specifies the area that is considered for the sorting, with number = 0 the entire length is examined. Offset specifies the position in the string from which the sorting begins. The direction can also be specified:

Direction

0

Descending

1

Ascending

String-ID

Value

0

...

1

" HWdellloor"

2

...

...

#VSS 1,"Hello World"

#VQC 1

...


Last error message in string register

#VSL

String-ID, Delete(1)

Save the error messages from the terminal in a string register (String-ID). The parameter Delete specifies the deletion behaviour of the error message:

Delete

0

Do not delete

1

Delete


Mix string register

#VMS

String-ID Start, String-ID End

The content of the registers remains, only the String-ID changes. A new assignment of string ID ⇔ content is now available.


Mix codes in string register

#VMC

String-ID, Number (0), Offset (0)

The content of a string register (String-ID) is interchanged randomly.

Number indicates the number of digits (= 0 complete string), Offset the starting point within the register.


Define regular expression (from V1.2)

#VSX

RegEx-ID, "regular expression"

Define a regular expression and save to RegEx-ID[0..9]. This command works together with many calculation commands to find specific strings in StringRegisters or StringArrays.

...

#VAU 0, 14,24, 0 /**Define unicode array, 14 entries, maximum stringlen=24

#VAW 0, "Alabama Slammer"; "Bloody Mary"; "Cosmopolitan"; "Fireball";

#VAW 0, "Kamikaze"; "Mai Tai"; "Mojito"; "Long Island Iced Tea"; "Pina Colada";

#VAW 0, "Gin Fizz"; "Jim Beam"; "Smirnoff"; "Tequila"; "Zombie"

#VSX 2, ".*am.*" /**set regular expression to RegExp-ID 2.

                /**Positive result if character combination 'am' is in String

#VRI 3, -1 /**Use Register R3 as result. Preload with -1 as result =-1 no occurrence

#MFM 1 /**Loop start

 #VRI 3, (strXA(2,0,++R3)) /**get new index where RegExp is true,

                           /**starting from last found index+1

 #MFS (R3<0), 1 /**skip next line if no occurrence

   #YPA A0I(R3) "\r\n" /**print arraystring into terminal window and add a new line

#MFJ(R3>=0) 1 /**loop end, Jump back to start if RegExp was true last time

...

Supported regular expressions:

^        Start of string

$        End of string

.        any single character

a?        zero or one of a, i.e. the term is optional

a+        one or more of a

a*        Zero or more of a

[ ]        Range selection, e.g. [a-z]

[^ ]        Range except selection range, e.g [^a-f]

( )        Capture everything enclosed max. 9 Subsections

|        or

\        Cancel special character (standard character)



Observe string register (from V1.5)

#VOS

String-ID, "String" [ID+1]; ...

The command defines the StringRegister as observed. If the register value changes, a macro can be called up automatically.


Delete Changeflag of string register (from V1.5)

#VDS

String-ID

Deletes the Changeflag of the StringRegister.


Read WIFI SSID to string register (from V1.5)

#VSW

String-ID

Writes the WIFI SSID to the String register with the specified String ID.


Read mDNS name to string register (from V1.5)

#VSN

String-ID, PLC address

Writes the mDNS/project name from the defined PLC address to the string register with the specified String ID. The command can only be used in the core.

Register

Set register (Integer)

#VRI

Register-ID, Value, Value1 [ID+1], ...

The command saves an integer value (32 bits) in the register set (Register-ID [0 ... 199]).

Register-ID

Value

0

10

1

42

2

-8

...

#VRI 0,10,42,-8

...

If the values are to be transmitted binary (communication with external µC), the switch "G" is used.


Set register (float)

#VRF

Register-ID, Value, Value1 [ID+1], ...

The command saves a float value (32 bit) in the register set (Register-ID [0 ... 199]).

       

Register-ID

Value

0

10.25

1

42.39

2

-8.19

...

#VRF 0,10.25,42.39,-8.19

...

If the values are to be transmitted binary (communication with external µC), the switch "G" is used.


Convert object string

#VRO

Register-ID, Obj-ID, Obj-ID1[ID+1], ...

Object strings are stored in registers. The object string is converted into a numerical value (automatically fitting as an integer or float). This function is mainly used for EditBoxes.

Register-ID

Value

0

...

1

42.5

2

...

...

#SED 1,"42.5"     /**Default text for EditBox

#VRO 1,1

...



Convert string register to register

#VRE

Register-ID Start, String-ID Source, Separator, Register-ID Number

Convert numeric string (String-ID Source) to register (Register-ID Start). Separator specifies the separator between the values. The number of valid values after the conversion is specified in the optional parameter Register-ID Number

Register-ID

Value

0

10

1

42.39

2

-8

10

3

...

#VSS 0,"10,42.39,-8";

#VRE 0,0,?,,10

...


Write register to RTC-RAM (if assembled only)

#VRW

ID, Register-ID, Register-ID1, ...

Buffer a Register-ID in the RAM of the RTC. ID [0 ... 7] indicates the storage space. The value is retained even after the module is switched off.


Read register from RTC-RAM (if assembled only)

#VRR

ID, Register-ID, Register-ID1, ...

Read back a value from the RTC-RAM (ID) and transfer it to the register (Register-ID).


Convert string register as calculation to register (integer)

#VCI

Register-ID, String-ID, String-ID1[ID+1], ...

Interpret the content of a string register as a calculation string. The result is stored in the register (Register-ID)

Register-ID

Vaule

0

-8

1

50

2

42

...

#VSS 0,"R0+R1";

#VCI 2,0

...


Convert string register as calculation to register (float)

#VCF

Register-ID, String-ID, String-ID1[ID+1], ...

Interpret the content of a string register as a calculation string. The result is stored in the register (Register-ID)

Register-ID

Value

0

-8.21

1

50.89

2

42.68

...

#VSS 0,"R0+R1";

#VCF 2,0

...



Sort register

#VQR

Register-ID Start, Register-ID End

The area of the registers (Register-ID Start to Register-ID End) are sorted.

Register-ID

Value before

Value after

0

2

-5

1

8

2

2

4

4

3

-5

8

...

#VRI 0,2,8,4,-5

#VQR 0,3

...


Mix register

#VMR

Register-ID Start, Register-ID End

The content of the registers remains, only the Register-ID changes. A new assignment of Register-ID ⇔ content is now available.


Observe register (from V1.4)

#VOR

Register-ID, "Register" [ID+1]; ...

The command defines the register as observed. If the register value changes, a macro can be called up automatically.


Delete Changeflag of register (from V1.4)

#VDR

Register-ID

Deletes the Changeflag of the register.


Assign a register to an analogue channel (from V1.4)

#VRA

Register-ID, Channel

The command assigns a register to an analogue channel.


Assign a register to an I/O Port channel (from V1.4)

#VRP

Register-ID, Port

The command assigns a register to an I/O port channel.

Array
Define array (Integer) (from V1.1)

#VAI

Array-ID, Number, Type(0)

The command defines an integer array (Array-ID [0 ... 199]) with the given Number of entries. The maximum length of the array respectively if the array has the desired length, can be checked with the calculation arE(). The Type specifies the behaviour when writing at the end of the array.

Type

0

Stop at end

1

Wrap around (ring buffer)



Define array (Float)

#VAF

Array-ID, Number, Type(0)

The command defines a float array (Array-ID [0 ... 199]) with the given Number of entries. The maximum length of the array respectively if the array has the desired length, can be checked with the calculation arE(). The Type specifies the behaviour when writing at the end of the array.

Type

0

Stop at end

1

Wrap around (ring buffer)


Array definieren (Unicode string) (from V1.2)

#VAU

Array-ID, Number, Stringlength, Type(0)

The command defines a string array (Array-ID [0 ... 199]) with the given Number of entries. The second parameter Stringlength gives the maximum length per entry. The maximum length of the array respectively if the array has the desired length, can be checked with the calculation arE(). The Type specifies the behaviour when writing at the end of the array.

Type

0

Stop at end

1

Wrap around (ring buffer)


Delete array (free memory)

#VAD

Array-ID

The command deletes an array (Array-ID [0 ... 199]) and releases the memory.


Fill array

#VAS

Array-ID, Value(0, all Elements), element index

The command fills all elements of the array (Array-ID [0 ... 199]) with the given Value. If  Value paramter is not sent, then the whole array is filled with 0. On the other hand the element index can specify which elements get the new value.


Assign values to array elements (with index)

#VAV

Array-ID, Index, Value, Value[Index+1], ...

The command assigns new Values to array elements, starting with the array Index.


Assign values to array elements (with current write pointer)

#VAW

Array-ID, Value 1, Value 2, ...

The command assigns new Values to array elements, starting with the current write pointer.


Set write and*or reading pointer

#VAP

Array-ID, WritePointer(-1), ReadPointer(-1), max. WritePointer

The command sets the Write and / or Read pointer of the array (Array-ID [0 ... 199]). If the pointer should remain unchanged, the respective parameter must be set to -1.


Sort array

#VQA

Array-ID, StartIndex, EndIndex(last Index), Stringlength(0), Stringoffest(0)

The values of the array (Array-ID [0 ... 199]) are sorted in the specified range (StartIndex to EndIndex). The last two parameters Stringlength and Stringoffset are only used if it is a stringarray (#VAU). Stringlength (total =0) specifies the number of characters, Stringoffset the character position to be considered for sorting.


Shuffle array

#VMA

Array-ID, StartIndex, EndIndex(last Index)

The command shuffles the values of the array in the specified range (StartIndex to EndIndex). The values remain unchanged. Only the order (indexes) is adjusted. A new assignment of the array indexes ⇔ values is now available ....


Observe array (from V1.4)

#VOA

Array-ID, "Array" [ID+1]; ...

The command defines the array as observed. If the array value changes, a macro can be called up automatically.


Delete Changeflag of array (from V1.4)

#VDA

Array-ID

Deletes the Changeflag of the array.