GET_SINT

Read a signed integer 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 result contains the signed integer value in the range from -128 to 127. The sign bit, i.e. bit number 7 of the result byte value, is extended to the upper bits. This means that if the sign bit is 0, then all upper bits are 0. If the sign bit is 1. all the upper bits are 1.

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 INT, DINT (ANY_SIGNED_INT)

Signed integer value in the range from -128 to 127. The sign bit, i.e. bit number 7 of the result byte value is extended to the upper bits.

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;
		iResult: INT:=0;
		awByteData: ARRAY [0..4] OF WORD:=[100,200,300,400,501];
		iOffs: INT:=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 := 7 ;
        NETWORK_BODY
B(B_CONTACT,,bStart,4,3,6,5,);
B(B_F,E_GET_SINT!,,11,2,19,7,,?DEN?DData?DiByteOffset?AENO?C);
B(B_VARIN,,awByteData,9,4,11,6,);
B(B_VAROUT,,iResult,19,4,21,6,);
B(B_VARIN,,iOffs,9,5,11,7,);
L(1,0,1,7);
L(1,4,4,4);
L(6,4,11,4);
        END_NETWORK_BODY
    END_NET_WORK
END_BODY

ST body

if (bSTart) then
	iResult:=GET_SINT(Data := awByteData, iByteOffset := iOffs);
end_if;

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