GET_BYTE

Read a byte value from byte data with offset

This function gets the 8-bit byte value of Data with iByteOffset denoting the offset in byte. The byte numbering starts from 0, which refers to the first byte of Data.

The lower byte of the result contains the byte value in the range from 16#00 to 16#FF, the upper bytes of the result byte value are filled with zeros.

Input

Data (ANY) all simple and derived data types (ARRAYs, DUTs) which do not contain BOOL

Byte data from which the byte is got

iByteOffset (INT, DINT, UINT, UDINT)

Byte offset relative to the first byte of Data starting from 0, must be greater than or equal to 0

Output

Unnamed output (WORD, DWORD)

Result byte value in the range from 16#00 to 16#FF, the upper bytes filled with zeros

Remarks

  • The byte offset is assumed to be greater than or equal to 0.

  • Please check the validity of the input data since the validity of the data to access is not checked.

NOTE

To get the best performance please use constant input values as much as possible!

Example

POU header

All input and output variables used for programming this function have been declared in the POU header.The same POU header is used for all programming languages.

	VAR
		bStart: BOOL:=FALSE;
		awByteData: ARRAY [0..4] OF WORD:=[100,101,111,2(0)];
		iOffset: INT:=2;
		wByteValue: WORD:=0;
	END_VAR

LD body

When the variable bStart is set to TRUE, the function is carried out.

BODY
    WORKSPACE
        NETWORK_LIST_TYPE := NWTYPELD ;
    END_WORKSPACE
    NET_WORK
        NETWORK_TYPE := NWTYPELD ;
        NETWORK_LABEL :=  ;
        NETWORK_TITLE :=  ;
        NETWORK_HEIGHT := 6 ;
        NETWORK_BODY
B(B_CONTACT,,bStart,5,1,7,3,);
B(B_F,E_GET_BYTE!,,8,0,16,5,,?DEN?DData?DiByteOffset?AENO?C);
B(B_VARIN,,awByteData,6,2,8,4,);
B(B_VAROUT,,wByteValue,16,2,18,4,);
B(B_VARIN,,iOffset,6,3,8,5,);
L(1,0,1,6);
L(1,2,5,2);
L(7,2,8,2);
        END_NETWORK_BODY
    END_NET_WORK
END_BODY

ST body

if (bStart) then
	wByteValue:=GET_BYTE(Data := awByteData, iByteOffset := iOffset);
end_if;

Modified on: 2025-02-27Feedback on this pagePanasonic hotline