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: 457
Joined: Mon May 28, 2007 10:12 am
Location: France
Contact:

How to store an array in

Post by Zax » Thu Dec 06, 2018 4:16 pm

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: 13824
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: How to store an array in

Post by Klaus » Thu Dec 06, 2018 4:35 pm

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: 9648
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: How to store an array in

Post by dunbarx » Thu Dec 06, 2018 5:04 pm

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: 9823
Joined: Sat Apr 08, 2006 7:05 am
Location: Los Angeles
Contact:

Re: How to store an array in

Post by FourthWorld » Thu Dec 06, 2018 5:25 pm

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: 457
Joined: Mon May 28, 2007 10:12 am
Location: France
Contact:

Re: How to store an array in

Post by Zax » Thu Dec 06, 2018 5:49 pm

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: 13824
Joined: Sat Apr 08, 2006 8:41 am
Location: Germany
Contact:

Re: How to store an array in

Post by Klaus » Thu Dec 06, 2018 6:06 pm

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: 457
Joined: Mon May 28, 2007 10:12 am
Location: France
Contact:

Re: How to store an array in

Post by Zax » Thu Dec 06, 2018 7:00 pm

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: 9648
Joined: Wed May 06, 2009 2:28 pm
Location: New York, NY

Re: How to store an array in

Post by dunbarx » Thu Dec 06, 2018 10:42 pm

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

Return to “Getting Started with LiveCode - Complete Beginners”