App with documents
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
App with documents
Hi all,
I'm creating an application that has to create docs, in them I would like to store text and some numbers. What is the best way to do this?
Is this lesson updated or with the current version of LiveCode there is a better approach? http://lessons.livecode.com/m/4071/l/70 ... n-xml-file
There you learn how to read from a XML file but there is also some tips I can use to write in it?
Unfortunately I can't use a plain document because I have also text with multiple lines and linefeeds.
I'm creating an application that has to create docs, in them I would like to store text and some numbers. What is the best way to do this?
Is this lesson updated or with the current version of LiveCode there is a better approach? http://lessons.livecode.com/m/4071/l/70 ... n-xml-file
There you learn how to read from a XML file but there is also some tips I can use to write in it?
Unfortunately I can't use a plain document because I have also text with multiple lines and linefeeds.
Re: App with documents
Hi Mag,
why not use a (invisible) Livecode stack?
Gazillion of storing possibilities with its custom properties and custom property sets!
Best
Klaus
why not use a (invisible) Livecode stack?
Gazillion of storing possibilities with its custom properties and custom property sets!
Best
Klaus
Re: App with documents
Without knowing more, a couple of thoughts:
1) The invisible stack is a good idea, especially if you don't know anything about databases, because it gives you what is, in effect, a database.
2) Look up "open file", "read from file", "write to file", and "close file". File operations in LC are stupid-simple. You don't have to limit yourself to xml, though. You can use a CSV-type format, but if you have CR's or LF's in your data, then just use some other character for the record delimiter, say ASCII(1), for instance.
3) If you know something about databases, the database routines in LC are also stupid-simple. Grab a free copy of Valentina to do your design and ad hoc queries, and eventually you'll maybe even use the Valentina ADK for reporting.
1) The invisible stack is a good idea, especially if you don't know anything about databases, because it gives you what is, in effect, a database.
2) Look up "open file", "read from file", "write to file", and "close file". File operations in LC are stupid-simple. You don't have to limit yourself to xml, though. You can use a CSV-type format, but if you have CR's or LF's in your data, then just use some other character for the record delimiter, say ASCII(1), for instance.
3) If you know something about databases, the database routines in LC are also stupid-simple. Grab a free copy of Valentina to do your design and ad hoc queries, and eventually you'll maybe even use the Valentina ADK for reporting.
Re: App with documents
Thank you Klaus, so I can store info in a stack created on the fly, save on the disk with any extension and then open it keep it invisible to get that info and to update it... seems fascinating, do you know if there is a resource online when I can learn more about this "technique"? Or do you have advices to share about it?Klaus wrote:Hi Mag,
why not use a (invisible) Livecode stack?
Gazillion of storing possibilities with its custom properties and custom property sets!
Best
Klaus
Last edited by Mag on Thu Nov 03, 2016 5:14 pm, edited 1 time in total.
Re: App with documents
Mikey wrote:Without knowing more, a couple of thoughts:
1) The invisible stack is a good idea, especially if you don't know anything about databases, because it gives you what is, in effect, a database.
2) Look up "open file", "read from file", "write to file", and "close file". File operations in LC are stupid-simple. You don't have to limit yourself to xml, though. You can use a CSV-type format, but if you have CR's or LF's in your data, then just use some other character for the record delimiter, say ASCII(1), for instance.
3) If you know something about databases, the database routines in LC are also stupid-simple. Grab a free copy of Valentina to do your design and ad hoc queries, and eventually you'll maybe even use the Valentina ADK for reporting.
Hi Mikey, thank you so much for the info about the info on the various possibilities. Very interesting the way to use some other character for the record delimiter so that I can use a text file, I did not think about it!
Re: App with documents
I'm not Klaus, but here is the simplest way:Mag wrote:Thank you Klaus, so I can store info in a stack created on the fly, save on the disk with any extension and then open it keep it invisible to get that info and to update it... seems fascinating, do you know if there is a resource online when I can learn more about this "technique"? Or do you have advices to share about it?
set the <property> of <object> to <data> // to set data
put the <property> of <object> into <container> // to get data
Let's say you were creating an address book (yeah yeah) and you had one contact per card..
stack = table
card = record
property = field
So we have our stack called "addressBook".. We're not going to bother naming the cards and will just use the numeric index.. Each contact has a first name and last name (this is a cheap address book)..
First thing we will need to do is add a new card to the stack, so we can store our contact's information..
Code: Select all
set the defaultStack to "addressBook"
create card
put it into tNewCard
Code: Select all
set the firstName of tNewCard to "Klaus"
set the lastName of tNewCard to "Major"
Code: Select all
put the firstName of tNewCard into tFirstName
put the lastName of tNewCard into tLastName
answer tFirstName && tLastName && "is pretty awesome"
Re: App with documents
Well, what not Klaus said!
Re: App with documents
hush you awesome you
Re: App with documents
Thank you for the very clear explanation!
is the same to
Or the "create invisible" command creates a special kind of object?
Code: Select all
create invisible stack stackName
show stack stackName
Code: Select all
create stack stackName
Re: App with documents
Hi Mag,
yep:
=
Best
Klaus
yep:
Code: Select all
create invisible stack stackName
show stack stackName
Code: Select all
create stack stackName
Best
Klaus
Re: App with documents
Super!
Your message contains 2 characters. The minimum number of characters you need to enter is 10.
Your message contains 2 characters. The minimum number of characters you need to enter is 10.
Re: App with documents
So to every invisible file stack, corresponds a visible window on the screen.
How do you recommend to track pairing? Sometimes the user moves the position of a document file on the disk and in this case I would lose the file location if I had closed the invisible file stack after reading the data...
How do you recommend to track pairing? Sometimes the user moves the position of a document file on the disk and in this case I would lose the file location if I had closed the invisible file stack after reading the data...
Re: App with documents
Hi Mag,
If a user moves any PREFS file it is the same as trashing it, means the prefs are GONE!
So store you PREF stacks in the prefs folder or any other location meant for them.
Best
Klaus
I do not know your data you need to store but I do not think this is really neccessary!Mag wrote:So to every invisible file stack, corresponds a visible window on the screen.
Not sure what you mean!?Mag wrote:How do you recommend to track pairing? Sometimes the user moves the position of a document file on the disk and in this case I would lose the file location if I had closed the invisible file stack after reading the data...
If a user moves any PREFS file it is the same as trashing it, means the prefs are GONE!
So store you PREF stacks in the prefs folder or any other location meant for them.
Best
Klaus
Re: App with documents
I would like to use one document file (a stack without scripts, just custom proprieties) for each window I create in the app. The technique described on your post in this topic.
When user close a window I save in this stack file its state, when the user opens the stack file I use the it to restore the window state.
Questions
1. Is better to close the stack file after I read on it or leave it open?
2. What happens if user moves the stack file from a location to another is there a way to know it so that I can safety save new data on it?
3. How can I know which window is associated with which stack file?
When user close a window I save in this stack file its state, when the user opens the stack file I use the it to restore the window state.
Questions
1. Is better to close the stack file after I read on it or leave it open?
2. What happens if user moves the stack file from a location to another is there a way to know it so that I can safety save new data on it?
3. How can I know which window is associated with which stack file?
Re: App with documents
I tried this approach and it's great, thank you for the suggestion. My only problem now is when user choose an integer as name for the file (or change it later on the Finder). It seems that LC confused for example stack 1, with stack with the name 1... and this complicate the handling of the document files...Klaus wrote:Hi Mag,
why not use a (invisible) Livecode stack?
Gazillion of storing possibilities with its custom properties and custom property sets!
Best
Klaus
http://forums.livecode.com/viewtopic.php?f=19&t=28378