Hello everybody!
I have made a FC with SCL, the problem is that don´t work. I have been testing the same code with VBScript and it´s work fine.
I don´t find where is the fault, if someone can help me to find it.
Thanks
I have made a FC with SCL, the problem is that don´t work. I have been testing the same code with VBScript and it´s work fine.
I don´t find where is the fault, if someone can help me to find it.
Thanks
Code:
FUNCTION FC200: VOID
VAR_INPUT
Cod_Barras : STRING;
Num_Cod : INT;
END_VAR
VAR_OUTPUT
Cod_BarrasOK: STRING;
Cod_BarrasNoK: BOOL;
Message : STRING;
END_VAR
VAR_TEMP
lenCod : INT;
Barcod: STRING;
index: INT;
c:STRING[1];
END_VAR
BEGIN
//Barcod:=''; lenCod:=0; index:=1;
c:='';
Barcod:=Cod_Barras;
lenCod:= LEN(S:=Barcod);
Cod_BarrasNoK :=0;
Message:='';
IF (lenCod <> Num_Cod) THEN
Cod_BarrasNoK :=1;
ELSE
FOR index := 1 TO lenCod BY 1 DO
c:= MID(IN := Barcod , L:= index, P:=1); // STRING
IF NOT EQ_STRNG(S1 := c ,S2 :='0' ) THEN //OR NE_STRNG(S1 := c ,S2 :='1' )// IF (c<>'0') OR (c<>'1') OR (c<>'2') OR (c<>'3') OR (c<>'4') OR (c<>'5') OR (c<>'6') OR (c<>'7') OR (c<>'8') OR (c<>'9') THEN
Message := 'The code isn´t valid';
Cod_BarrasNoK :=1;
EXIT;
END_IF;
END_FOR;
//Cod_BarrasNoK := 0;
END_IF;
IF Cod_BarrasNoK=0 THEN
Cod_BarrasOK:=Barcod;
Message:='';
END_IF;
END_FUNCTION