rusty
rusty copied to clipboard
cannot assign 'DINT' to 'STRING'
PROGRAM main
VAR
a : STRING[80];
b : STRUCT1;
END_VAR
a := UINT_TO_STRING(b.var10); //var10 is UINT
END_PROGRAM
TYPE STRUCT1 : STRUCT
var10 : UINT := 10;
END_STRUCT END_TYPE
FUNCTION UINT_TO_STRING : DINT
VAR_INPUT
in : UINT;
END_VAR
END_FUNCTION
error: Invalid assignment: cannot assign 'DINT' to 'STRING'
The function UINT_TO_STRING is not yet implemented in the standard functions, but the signature here is wrong, and therefore you get an error, the signature should be
FUNCTION UINT_TO_STRING : STRING
VAR_INPUT
in : UINT;
END_VAR
END_FUNCTION
we have a new error case here
code example:
PROGRAM mainProg
VAR
Conv : STRING[125];
Index : USINT;
Args : argsSTR;
END_VAR
Conv := BOOL_TO_STRING(Args.b[Index]);
END_PROGRAM
TYPE argsSTR :
STRUCT
b : ARRAY[0..4] OF BOOL ;
i : ARRAY[0..4] OF DINT ;
END_STRUCT
END_TYPE
error: Invalid assignment: cannot assign 'DINT' to 'STRING[125]' Error: E001: Compilation aborted due to critical errors