New features for the Matrix42 Package Robot Part II

Moderator: MVogt

Beiträge: 323
Registriert: 03. Okt 2009, 08:57
Wohnort: Herrenstr.11 * 76706 Dettenheim

New features for the Matrix42 Package Robot Part II

Beitrag von Theo_Gottwald » 04. Aug 2018, 08:05

If you go deeper into Scripting, you sometimes have to deal with "set or clear bits".
For this you had to get into mathematics until now, but now here is the new BIT\ command.

Code: Alles auswählen

This command can be used to perform bit operations of all sorts.

The commands "and", "or", "xor" and "not" do exactly what their names say, with the given parameters "p1" and "p2".
p1 and p2 are considered as 32-bit values.

"set" - sets bit p2 in p1
"clr" - clear bit p2 in p1
"toggle" - changes bit p2 to p1 (from 0 to 1 or vice versa)
"get" - returns the value of bit p2 in p1.

The result is assigned to a program-internal variable, which you can access with the string "$v1$". If you specify the character ">" at the end of the data part and then a variable name ("$$ xyz"), the result is written directly into this variable.

Sample Code:

Code: Alles auswählen

BIT\and|4|1                           ' $v1$ = 0
BIT\or|4|1                            ' $v1$ = 5
BIT\set|4|1>$$xyz                     ' $$xyz = 5
BIT\get|4|1                           ' $v1$ = 0
BIT\not|65535                         ' $v1$ = -65536 (not(0000ffff) -> ffff0000)


Zurück zu „Package Robot“

Wer ist online?

Mitglieder in diesem Forum: 0 Mitglieder und 1 Gast