I'm having a problem again. This time I'm trying to read a string from a DB and compare it to a string given by an input variable in the FB. The problem seems to be when reading the string from the DB. It should be a string containing '0', '1' or '2' but in the FB it is a dword containing F013100. Here is some of the code:
Code:
FUNCTION_BLOCK Recept_hantering
// *** Variable declarations ***
//Temporary variables
VAR_TEMP
loopnumber : INT;
i : INT;
temp_article_nr : STRING[15];
END_VAR
//Static variables
VAR
area_start : INT;
editable_start : INT;
active_start : INT := 0;
END_VAR
//Input parameters
VAR_INPUT
load : BOOL;
save : BOOL;
activate : BOOL;
recipe : BLOCK_DB;
article_or_position : BOOL;
sum_articles : INT;
article_datalength : INT;
article_nr : STRING[15];
END_VAR
// *** Program start ***
BEGIN
loopnumber := sum_articles;
editable_start := article_datalength;
temp_article_nr := '';
temp_article_nr := article_nr;
area_start := article_datalength;
i := 0;
//Check for model with matching article number
REPEAT
i := i + 1;
UNTIL temp_article_nr = DINT_TO_STRING(DWORD_TO_DINT(recipe.DD[area_start + article_datalength * i])) OR i > (loopnumber - 1) END_REPEAT;
END_FUNCTION_BLOCK