How to store an array in

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
Zax
Posts: 519
Joined: Mon May 28, 2007 10:12 am
Contact:

How to store an array in

Post by Zax »

Hello,

I have a standalone app with several cards. Each card has a field with styled text.
Is there a way to save all these cards fields in a single xml file?

I know I can convert a styled field into an array with the command:

Code: Select all

put the styledText of fld ...
I also found how to store an array in a text file, but it doesn't solve my problem:
http://lessons.livecode.com/m/4071/l/95 ... e-it-again

Thank you.
Klaus
Posts: 14324
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: How to store an array in

Post by Klaus »

Hi Zax,

does it have to be an ARRAY? "the htmltext of fld xyz" and "the rtftext of fld xyz" will also preserve the formatting of the field. This way you could also store everything into a XML file.

My XML-knowledge is a bit rusty, but you get the picture. :D


Best

Klaus
dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10501
Joined: Wed May 06, 2009 2:28 pm

Re: How to store an array in

Post by dunbarx »

What Klaus said.

I don't think the OP meant an array variable, only a dataset of some kind.

The word "array" is often misused this way.

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

Re: How to store an array in

Post by FourthWorld »

Does the output have to be XML? That's quite doable, but to explore the full range of options it would be helpful to know what programs will be consuming the data.
Richard Gaskin
LiveCode development, training, and consulting services: Fourth World Systems
LiveCode Group on Facebook
LiveCode Group on LinkedIn
Zax
Posts: 519
Joined: Mon May 28, 2007 10:12 am
Contact:

Re: How to store an array in

Post by Zax »

Well, styledText seems to be a real array ;)
http://livecode.wikia.com/wiki/StyledText

Concerning the XML format, I used to use XML file to store user's preferences. In this case, I would like to store styled texts of all cards. If my problem can be solved with another input/output format, it's OK for me.

Each card also has a title (its name in fact) that I also would like to store.
So, when the user launch the standalone, a text file should be read (XML or something else) to retreive cards' name and the corresponding styled text for each card.
Klaus
Posts: 14324
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: How to store an array in

Post by Klaus »

Hi Zax,

yep, "the styledtext of fld xyz" not only seems to be, but in fact IS an ARRAY, that's why I was asking if this was mandatory.

Just create a node for each card with "number", "title" and "fieldcontent" (and/or whatever you need to save) and just store -> the htmltext of fld "your field here" in the latter one.

Then read that XML file in when the app starts the next time and re-create the fields content of each card.


Best

Klaus
Zax
Posts: 519
Joined: Mon May 28, 2007 10:12 am
Contact:

Re: How to store an array in

Post by Zax »

The htmltext of fld "MyStyledTextField" is the solution.

Problem solved, thank you very much, Klaus :)
dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10501
Joined: Wed May 06, 2009 2:28 pm

Re: How to store an array in

Post by dunbarx »

yep, "the styledtext of fld xyz" not only seems to be, but in fact IS an ARRAY
Yep.

I was thinking (not thinking at all?) about the htmlText

Craig
Post Reply