Commands and functions
P.
221 of 349
Stringcast
Stringset
Definition
●
Function
stringcast
(
string, data, pos
)
Arguments
●
3 arguments:
string
of data type c1400,
data
of arbitrary data type,
pos
of data type u16
Effect
●
string
: Character string (1400 bytes) a certain number of bytes of which shall be copied to
another data type. The number of bytes is defined by the data type of
data
. At this, only the
raw data will be copied (cast) and no conversion of the data types is performed.
●
pos
: The position of the 1st character of the character string to be copied to the target type.
Data type result (Return)
●
n Bits (n = length of
data
in bytes) from
string
, i.e. raw data are returned.
Example: Conversion of a string into a floating point number
In the variable a=$98$, the first two bytes character shall be written to a floating point number
Implementation in the user program:
a=$98$
z=stringcast(a,0.0,0u16)
// z interprets 0x39 0x38 (ASCII „98“) as „72.9600000“
Note:
In connection with
stringset
and
stringcast
, c1400 character strings can be used to manage data
arrays. See the example of
stringset
on page 221.
Definition
●
Function
stringset
(
string, data, pos
)
Arguments
●
3 arguments:
string
of data type c1400,
data
of arbitrary data type,
pos
of data type u16
Effect
●
string
:Character string one ore more bytes of which shall be replaced.
●
data
: This bytes (= characters) replace characters of
string
.
●
pos
: The position of the bytes in
string
to be replaced. The number of bytes arises from the
data type of
data
.
Data type result (Return)
●
none
Example: Replace a character sequence
In the variable a=$ nnette$, the 1st character shall be set to 65 =('A').
Implementation in the user program:
a=$ nnette$
if systemstart() then stringset(a,65,0u16) endif
Example: Create and read a data array
The 15-min-values of the temperature from group address '1/1/1'f16 shall be stored in a data
array. At the same time, the temperature difference of the last change shall be extracted from
this data array.
The implementation is as follows. Note, the user has to be aware of the byte length of the data.
HandbuchEibPC_USA-30.odt, 2017-05-11
Enertex
®
Bayern GmbH - Erlachstraße 13 - 91301 Forchheim - [email protected]