Variable_To_String Limitations
Mathieu
Posts: 25
Hello,
i had already use the Variable_To_String function to save data on flash drive.( with the file_write keyword)
Today i tried to save a structure, i already did that but never with interger array on the struct. it seems not working ! Someone tried it already?
my code example :
for testing with the struct :
there is no error during encoding and decoding variable, no error during writing to file ans reading, but i never get back my integer array. Single integer is right read, but not array.
Char and char array are right read.
any ideas?
i had already use the Variable_To_String function to save data on flash drive.( with the file_write keyword)
Today i tried to save a structure, i already did that but never with interger array on the struct. it seems not working ! Someone tried it already?
my code example :
// Writing the struct on file define_call 'Ecriture_Fichier_Preset_Grille_HDSDI' { local_var slong File slong Convert_Success slong File_Result char Binary_String[90000] File = File_Open('/Grilles/Grille_HDSDI.txt',2) Convert_Success = Variable_To_String(Tab_Preset_Grille_HDSDI, Binary_String, 1) File_Result = File_Write(File, Binary_String, 90000) File_Close(File) } // reading struct from file define_call 'Lecture_Fichier_Preset_Grille_HDSDI' { local_var slong File slong Convert_Success slong File_Result char Binary_String[90000] File = File_Open('/Grilles/Grille_HDSDI.txt',1) Convert_Success = File_Read(File, Binary_String, 90000) File_Result = String_To_Variable(Tab_Preset_Grille_HDSDI, Binary_String, 1) File_Close(File) }
for testing with the struct :
structure Struct_Preset_Grille_HDSDI { Char Label[11][50] integer Preset_HDSDI[64] // <= here is the issue !!!! integer I_count // <= no issue }
there is no error during encoding and decoding variable, no error during writing to file ans reading, but i never get back my integer array. Single integer is right read, but not array.
Char and char array are right read.
any ideas?
0
Comments
I tried to change my way of thinking, so if we could only use char array, i convert all my interger array to char array and save my char array. after that we i read the char array i convert the string in integer... it's not a nice solution but it works..
my decoding and encoding calls
my final writing and reading functions my new temprary struc for the conversion
BEFORE the struct is written out to file.
Edit: Oops, typo in my code. Based on your code sample, the code would be as above.
why does it work with char array and not with interger ? i don't really understand your answer...