External file with settings (like .xml)?

Anything beyond the basics in using the LiveCode language. Share your handlers, functions and magic here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
cu3e
Posts: 46
Joined: Mon May 23, 2011 10:03 am

External file with settings (like .xml)?

Post by cu3e » Mon Aug 29, 2011 12:25 pm

Hello, today I have the following question.

Does LiveCode support external setting files like .xml or any other possibility?

I want to archive the following.

A LiveCode App calls a specific file (team_settings:xml) for example which is on a server. All LIveCode Clients can connect to the file. The file host a couple of simple Variables with a Picture Link. Example:

Code: Select all

<member_id>00001</member_id>
<member_name>Joe Doe</member_named>
<member_picture>[/server/pictures/member00001.png]</member_picture>
<member_title>Executive Officer</member_title>
<member_phone>0000.0000.000</member_phone>
<member_email>joe.doe@company.com</member_email>

<member_id>00002</member_id>
<member_name>Lisa Doe</member_named>
<member_picture>[/server/pictures/member00002.png]</member_picture>
<member_title>Artist</member_title>
<member_phone>0000.0000.000</member_phone>
<member_email>lisa.doe@company.com</member_email>
The LiveCode App pulls all infos and show it like the picture and credentials.

The reason why I want use a external script is that I can easily add more entries without changing all LiveCode Apps.


It that possible, if yes? Any tutorials available?

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

Re: External file with settings (like .xml)?

Post by Klaus » Mon Aug 29, 2011 1:50 pm

Hi cu3e,

sure this is possible :D

Load the file:

Code: Select all

...
put url("http://www.yourserver.com/thefile.xml") into tXMLFile

## Check for possible problems!
if the result <> empty then
  answer "Error" && the result"
 exit to top
end if
## Now you can parse your XML and extract what you need.
...
Check this url to get started with XML:
http://www.troz.net/rev/
Scroll down to "Sample stacks" -> "xmldemo1"


Best

Klaus

cu3e
Posts: 46
Joined: Mon May 23, 2011 10:03 am

Re: External file with settings (like .xml)?

Post by cu3e » Mon Aug 29, 2011 2:07 pm

Great! Thank you Klaus.

But how do I put a xml string into a field? Like

Code: Select all

<CATALOG>
<CD>
<NUMBER>1</NUMBER>
<ARTIST>Bob Dylan</ARTIST>
<COUNTRY>USA</COUNTRY>
<COMPANY>Columbia</COMPANY>
<PRICE>10.90</PRICE>
<YEAR>1985</YEAR>
</CD>
<CD>
<NUMBER>2</NUMBER>
<ARTIST>Bonnie Tylor</ARTIST>
<COUNTRY>UK</COUNTRY>
<COMPANY>CBS Records</COMPANY>
<PRICE>9.90</PRICE>
<YEAR>1988</YEAR>
</CD>
I want the Artist from CD 2 in Field "1" ?

put "artist" from "CD 1" into field "1"?

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

Re: External file with settings (like .xml)?

Post by Klaus » Mon Aug 29, 2011 3:03 pm

Hi cu3e,

well, this not something that can be explained in a few sentences here!
Check the above url to get used to XML in general and in LiveCode :D


Best

Klaus

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: External file with settings (like .xml)?

Post by jmburnod » Mon Aug 29, 2011 10:26 pm

Hi cu3e,
But how do I put a xml string into a field?
I've done a little stack, one way to make the job (in attachment)

Best regard

Jean-Marc
Attachments
SearchFind.rev.zip
(1.36 KiB) Downloaded 292 times
https://alternatic.ch

cu3e
Posts: 46
Joined: Mon May 23, 2011 10:03 am

Re: External file with settings (like .xml)?

Post by cu3e » Tue Aug 30, 2011 12:49 pm

jmburnod wrote:Hi cu3e,
But how do I put a xml string into a field?
I've done a little stack, one way to make the job (in attachment)

Best regard

Jean-Marc

Thank you very much jean-Marc, thats awesome! But where can I found the script? The only script I found was on that search button

Code: Select all

on mouseUp
   debGetArtist
end mouseUp
where/what is this "deb"?

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

Re: External file with settings (like .xml)?

Post by Klaus » Tue Aug 30, 2011 1:19 pm

Hi cu3e,

always check the card (here you find the debGetArtist handler) and stack script(s), too! 8)
And the groups script, if the object is part of a group.


Best

Klaus

P.S.
Jean-Marc provided a cool search script :D , but this has nothing to do with XML!

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: External file with settings (like .xml)?

Post by jmburnod » Tue Aug 30, 2011 3:21 pm

Hi cu3e,
where can I found the script
It is in the card script

Klaus said :
Jean-Marc provided a cool search script , but this has nothing to do with XML!
Yes, i don't know XML (at this moment) :D

Best from Geneva

Jean-Marc
https://alternatic.ch

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

Re: External file with settings (like .xml)?

Post by Klaus » Tue Aug 30, 2011 4:30 pm

Bonjour Jean-Marc,

the hint (... not XML) was for cu3e :D

But if you need to dive into XML in LiveCode at some time, check Sarah's above mentioned stack!
Very informative, it got me started with XML!


Best

Klaus

jmburnod
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 2729
Joined: Sat Dec 22, 2007 5:35 pm
Contact:

Re: External file with settings (like .xml)?

Post by jmburnod » Tue Aug 30, 2011 7:19 pm

Guten Abend Klaus,
the hint (... not XML) was for cu3e :D
To late. I was so angry after your post i have eaten my computer :shock:
check Sarah's above mentioned stack! Very informative, it got me started with XML!
Oh yes.I downloaded it.Good job, clever approach.
I'm sur it will be very useful.
Thank again fo that

Jean-Marc
https://alternatic.ch

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

Re: External file with settings (like .xml)?

Post by Klaus » Wed Aug 31, 2011 11:19 am

Bonjour Jean-Marc,
jmburnod wrote:Guten Abend Klaus,
the hint (... not XML) was for cu3e :D
To late. I was so angry after your post i have eaten my computer :shock:
LOL :D

And, was it tasty? 8)

Post Reply