String length limitation for MpRecipeCsv

I have setup a Csv loading with the mapp service MpRecipeCsv and it seems that the length of the strings that are imported are limited to 85 chars. Does anyone heve the same issue?
How to set up the reader so that it can read longer strings?
My variable structure is defined with STRING[300], so in theory it should hold my string which is 125 chars long.
Saving and loading the Csv work fine…

This is the definition of the type structure:

TYPE
	RT_Var_change : 	STRUCT 
		Procedure_repeat : INT;
		Headers_to_write : ARRAY[0..15]OF STRING[80];
		TimeStep : ARRAY[0..200]OF INT;
		Process_Var0 : ARRAY[0..200]OF LREAL;
		Process_Var1 : ARRAY[0..200]OF LREAL;
		Process_Var2 : ARRAY[0..200]OF LREAL;
		Process_Var3 : ARRAY[0..200]OF LREAL;
		Process_Var4 : ARRAY[0..200]OF LREAL;
		Process_Var5 : ARRAY[0..200]OF LREAL;
		Process_Var6 : ARRAY[0..200]OF LREAL;
		Process_Var7 : ARRAY[0..200]OF LREAL;
		Process_Var8 : ARRAY[0..200]OF LREAL;
		Process_Var9 : ARRAY[0..200]OF LREAL;
		Process_Var10 : ARRAY[0..200]OF LREAL;
		Process_Var11 : ARRAY[0..200]OF LREAL;
		Process_Var12 : ARRAY[0..200]OF LREAL;
		Process_Var13 : ARRAY[0..200]OF LREAL;
		Process_Var14 : ARRAY[0..200]OF LREAL;
		Process_Var15 : ARRAY[0..200]OF LREAL;
		Process_VarString0 : ARRAY[0..200]OF STRING[300];
		Process_VarString1 : ARRAY[0..200]OF STRING[300];
		Process_VarString2 : ARRAY[0..200]OF STRING[300];
		Process_VarString3 : ARRAY[0..200]OF STRING[300];
		Process_VarString4 : ARRAY[0..200]OF STRING[300];
		Process_VarString5 : ARRAY[0..200]OF STRING[300];
		Process_VarString6 : ARRAY[0..200]OF STRING[300];
		Process_VarString7 : ARRAY[0..200]OF STRING[300];
		Process_VarString8 : ARRAY[0..200]OF STRING[300];
		Process_VarString9 : ARRAY[0..200]OF STRING[300];
		Process_VarString10 : ARRAY[0..200]OF STRING[300];
		Process_VarString11 : ARRAY[0..200]OF STRING[300];
		Process_VarString12 : ARRAY[0..200]OF STRING[300];
		Process_VarString13 : ARRAY[0..200]OF STRING[300];
		Process_VarString14 : ARRAY[0..200]OF STRING[300];
		Process_VarString15 : ARRAY[0..200]OF STRING[300];
	END_STRUCT;
END_TYPE

Hi!

I cannot reproduce this in a project I have created… Some thoughts:

  • Are you only checking the value with the “Watch” window of Automation Studio?
    • This will (at least by default) only display up to 85 characters (the string can and will contain more, but it will not be displayed/cut off)
    • I am not sure if there is a way in Automation Studio to make it display more characters…
    • I would suggest you try a real string comparison in this case (rather than relying on the “Watch” window)
  • Does your string contain any “special” characters? More specifically the “Column Separator”?
    • I am not sure if MpRecipe will in this case read the complete string.
    • If this is the case, you can try to change the column separator to a character you are not using.

Just for reference, this is the code I used to try it:

PROGRAM _INIT
    Recipe.Enable := TRUE;
    Recipe.MpLink := ADR(gRecipeCsv);
    Recipe.DeviceName := ADR('USER');
    Recipe.FileName := ADR('MyFile.csv');
    Recipe();
    
    RegPar.Enable := TRUE;
    RegPar.MpLink := ADR(gRecipeCsv);
    RegPar.PVName := ADR('Program:Value');
    RegPar();
    
    Value := 'This is a very long string that can hold a lot of text. I do not know what else I can type here to make it longer other than useless characters... It is a total of 189 characters long now.';
END_PROGRAM

PROGRAM _CYCLIC
    Recipe();
    RegPar();
    
    IF (Value = 'This is a very long string that can hold a lot of text. I do not know what else I can type here to make it longer other than useless characters... It is a total of 189 characters long now.') THEN
        IsMatching := TRUE;
    ELSE
        IsMatching := FALSE;
    END_IF;
END_PROGRAM

And the corresponding “var” file (for completeness):

VAR
    Recipe : MpRecipeCsv;
    RegPar : MpRecipeRegPar;
    Value : STRING[300];
    IsMatching : BOOL;
END_VAR

And this is what I then see in the Watch window:
Screenshot 2025-03-06 142521

Hi,
If you use the Debugger Watch, you can see more than 85 characters:

Best regards,
Simon

4 Likes


This is the line of my csv where the string is inside, it is a filepath and contains some special characters, but when I want to load it in it gets truncated.
E:\Shared\SD_Files\xxx\yyyyy\Paths\yyyy\zzzz\xxx\SD_File_135A_EXC_1_0p6_to_2Apcm2_IDC_1350p0A_60.tab
gets truncated to:
'E:\Shared\SD_Files\xxx\yyyyy\Paths\yyyy\zzzz\xxx\SD_File_135A_EXC_1_0p6_to_2Apcm2_ID

And yes I know that the watch windows cannot display the whole thing.
But I take the string and serialize it together with some others to a json format and the truncated string is further processed.

The function which writes the imported string to the next destination is with strcpy:
strcpy(Headers_Pointer[Indices[0]], ADR(Variables_RuntimeChange.Process_VarString0[counter]));
Headers_Pointer is an UDINT Array with adresses inside

Okay it seems that:
Testlen := strlen(ADR(Variables_RuntimeChange.Process_VarString0[0]));
gives me back 100 which is a correct import!

So the problem must be somewhere furhter down my code