ClearRawBytes用于將rawbytes變量的所有內容設置為0。
基本示例
該指令的基本示例如下所示。
示例1
VAR rawbytes raw_數(shù)據(jù);
VAR num整數(shù):=8
VAR num float:=13.4;
PackRawBytes integer,raw\u data,1\IntX:=力;
PackRawBytes float,raw\u data,(RawBytesLen(raw\u data)+1)\Float4;
ClearRawBytes raw\u data\FromIndex:=5;
在前4個字節(jié)中放置整數(shù)的值(從索引1開始),在接下來的4個字節(jié)中放置整數(shù)的值
從索引5開始計算浮點值。
示例中的后一條指令從索引5開始清除原始_數(shù)據(jù)的內容,即。
浮點將被清除,但整數(shù)保留在raw_數(shù)據(jù)中。中有效字節(jié)的當前長度


Usage
ClearRawBytes is used to set all the contents of a rawbytes variable to 0.
Basic examples
A basic example of the instruction is illustrated below.
Example 1
VAR rawbytes raw_data;
VAR num integer := 8
VAR num float := 13.4;
PackRawBytes integer, raw_data, 1 \IntX := DINT;
PackRawBytes float, raw_data, (RawBytesLen(raw_data)+1) \Float4;
ClearRawBytes raw_data \FromIndex := 5;
In the first 4 bytes the value of integer is placed (from index 1) and in the next 4 bytes
starting from index 5 the value of float.
The last instruction in the example clears the contents of raw_data, starting at index 5, i.e.
float will be cleared, but integer is kept in raw_data. Current length of valid bytes in







客服1