storing data in a file

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
tturner43
Posts: 21
Joined: Fri May 27, 2011 10:01 am
Contact:

storing data in a file

Post by tturner43 » Tue May 31, 2011 8:47 pm

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

BvG
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 1239
Joined: Sat Apr 08, 2006 1:10 pm
Contact:

Re: storing data in a file

Post by BvG » Wed Jun 01, 2011 2:27 am

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.
Various teststacks and stuff:
http://bjoernke.com

Chat with other RunRev developers:
chat.freenode.net:6666 #livecode

tturner43
Posts: 21
Joined: Fri May 27, 2011 10:01 am
Contact:

Re: storing data in a file

Post by tturner43 » Wed Jun 01, 2011 4:36 pm

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.

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: storing data in a file

Post by Klaus » Wed Jun 01, 2011 7:02 pm

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

tturner43
Posts: 21
Joined: Fri May 27, 2011 10:01 am
Contact:

Re: storing data in a file

Post by tturner43 » Sat Jun 04, 2011 3:00 pm

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.

FourthWorld
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10043
Joined: Sat Apr 08, 2006 7:05 am
Contact:

Re: storing data in a file

Post by FourthWorld » Sat Jun 04, 2011 3:05 pm

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
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn

Post Reply