I would like to store the content of a data grid in a file.  I tried the following without success:
put the dgData of group "test" into pArrayData
open file "Test" for binary write
write arrayEncode(pArrayData) to file "test"
close file "Test"
Nothing is written to the file.
I tried also
open file "Test" for binary read
read from file "Test" until empty
put arrayDecode(it) into pArrayData
close file "Test"
set the dgData of group "test" to pArrayData
I suppose I could convert the array to a variable and then save the variable and vice versa, but I got the impression from the User Dictionary that the code above would work.
Any help much appreciated.
			
			
									
									
						arrayEncode
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Re: arrayEncode
drOrganized,
I did not get your script to work either. I don't know why. But works for me.
I reimported the data into the datagrid and with arrayDecode it works.
regards
Bernd
			
			
									
									
						I did not get your script to work either. I don't know why. But
Code: Select all
   put the dgData of group "DataGrid 1" into pArrayData
   put arrayEncode(pArrayData) into pArrayData
   put specialfolderpath ("desktop") & "/" into aPath
   put "arrayExportTest" after aPath
   put pArrayData into URL ("binfile:" & aPath)I reimported the data into the datagrid and with arrayDecode it works.
regards
Bernd
- 
				FourthWorld
- VIP Livecode Opensource Backer 
- Posts: 10065
- Joined: Sat Apr 08, 2006 7:05 am
- Contact:
Re: arrayEncode
The difference between the working an non-working scripts suggests the issue is in the way the data is read.  
I wonder if changing "read until empty" to "read until EOF" would work.
			
			
									
									I wonder if changing "read until empty" to "read until EOF" would work.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
						LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Re: arrayEncode
drOrganized,
here is the script that reads the data and populates the datagrid
this works for me
regards
Bernd
			
			
									
									
						here is the script that reads the data and populates the datagrid
Code: Select all
on mouseUp
    put specialfolderpath ("desktop") & "/" into aPath
    put "arrayExportTest" after aPath
    breakpoint
   put url ("binfile:"& aPath) into pArrayData
   put arrayDecode(pArrayData) into pArrayData
   set the dgData of group "DataGrid 1" to pArrayData
end mouseUpregards
Bernd