bara_hence
Member
I have this code:
The trouble is when assigning the string variable if for example dettarecept holds in byte 1 20(The lenght) and in byte 2 97 (the character a) the other string holds 20 in its first two bytes.. So something must be wrong but what??
Code:
FUNCTION_BLOCK FB100
VAR_INPUT
DennaForm : INT;
DettaRecept : STRING[20];
FormTakt : BOOL;
END_VAR
VAR
SenasteForm : INT;
SenasteRecept : STRING[20];
NyForm : BOOL;
NyRcpt : BOOL;
END_VAR
VAR_OUTPUT
NyFormRcpt : BOOL;
END_VAR
BEGIN
IF (Formtakt=1) AND (DennaForm<>0)AND(DennaForm<>SenasteForm)
THEN NyForm:=1;
ELSE NyForm:=0;
END_IF;
IF (Formtakt=1) AND (DettaRecept<>'') AND (DettaRecept<>SenasteRecept)
THEN NyRcpt:=1;
ELSE NyRcpt:=0;
END_IF;
IF (NyRcpt=1) OR (NyForm=1)
THEN NyFormRcpt:=1;
ELSE NyFormRcpt:=0;
END_IF;
SenasteRecept := DettaRecept;
SenasteForm := DennaForm;
END_FUNCTION_BLOCK
The trouble is when assigning the string variable if for example dettarecept holds in byte 1 20(The lenght) and in byte 2 97 (the character a) the other string holds 20 in its first two bytes.. So something must be wrong but what??