Page 1 of 1
storing data in a file
Posted: Tue May 31, 2011 8:47 pm
by tturner43
Hi,
In another IDE we store our data as binary objects into a file.... we then offer file new, save, etc.
How do we do this in runrev and still make it cross platform for mac and windows?
i.e. suggestions on "storing data"
Also in VB6 we used "user defined types" to create the data structures... how does one organize data in memory in runrev?
Thanks
Re: storing data in a file
Posted: Wed Jun 01, 2011 2:27 am
by BvG
for basic stuf, you can put stuff into a file or binfile url. you can also save your data into stacks, or use databases, depending on your need. for text files this is pretty easy:
Code: Select all
ask file "where to save the data"
put theData into url ("file:" & it)
you do not mess with the data structure in memory livecode does all that behind the scenes for you, mostly this is because there is no variable types at all.
Re: storing data in a file
Posted: Wed Jun 01, 2011 4:36 pm
by tturner43
Where would I learn more about how we can structure "theData"? Our app has numerous complicated objects as well as a variable number of those objects that need to be stored... i.e. if we model say an "investment"... the client might have 7 or 27 investments... and each investment has a balance, contribution rate, return, etc.
Re: storing data in a file
Posted: Wed Jun 01, 2011 7:02 pm
by Klaus
Hi tturner43,
what exactly are the "complicated objects" you want to store in a file?
In any case it is up to you to define the structure of your data!
"theData" is just an arbitrary name for a variable in Björnkes example.
You can store binary data using the keyword "binfile" and any text using "file".
Example:
...
put variable_with_binary_data into url("binfile:" & specialfolderpath("desktop") & "/binary stuff.bin")
...
put variable_with_text into url("binfile:" & specialfolderpath("desktop") & "/a text file.txt")
...
Will save the stuff on your desktop
Best
Klaus
Re: storing data in a file
Posted: Sat Jun 04, 2011 3:00 pm
by tturner43
Yes I understand what he meant.... I am totally green to runrev... am trying to decide whether to use it or realbasic...
Looking for tutorial or examples on defining "theData" to see how that's done... so in "defining the structure of my data".... just need some examples on how that is done to see what it is like.
Thanks.
Re: storing data in a file
Posted: Sat Jun 04, 2011 3:05 pm
by FourthWorld
You can use stack files as documents. Kinda handy: properties can store even binary data, and cards can store native objects like images.
For tips on handling document files in a standalone, this article is helpful:
http://livecodejournal.com/tutorials/sa ... ution.html