XML-Style Script-Command - best practise??

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
HansImGlueck
Posts: 4
Joined: Thu Oct 03, 2013 9:14 am

XML-Style Script-Command - best practise??

Post by HansImGlueck » Mon Oct 07, 2013 12:12 pm

Hi again (second post...),

I need to send a long XML-style script command to a Server via an open socket (write ... to socket Server:port). The communication with the server is presumed to be encoded in UTF-8.
Here is an example:

Code: Select all

CG 1 ADD 0 "TEMPLATE" 1 "<templateData><componentData id=\"f0\"><data id=\"text\" value=\"NAME\"></data></componentData><componentData id=\"f1\"><data id=\"text\" value=\"FUNCTION\"></data></componentData></templateData>"
(for those, who are interested for what's it for - it's an AMCP-command for the Caspar CG Server 2.03 Graphic-Server)

In the example are three string-Variables, which must be dynamically selectable (via Combo box, selectable text fields or whatever). These are TEMPLATE (for a Flash-Template), NAME and FUNCTION.
I tried to build the whole command-string with put "..." & TEMPLATE & "..." & NAME & "..." & FUNCTION & "..." to a string-variable, but that doesn't work. The reason for that are the many quotes in the command-string I guess... I don't know.
Any idea to solve that Problem??

Greets,
Martin

bangkok
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 937
Joined: Fri Aug 15, 2008 7:15 am

Re: XML-Style Script-Command - best practise??

Post by bangkok » Mon Oct 07, 2013 12:23 pm

HansImGlueck wrote: I tried to build the whole command-string with put "..." & TEMPLATE & "..." & NAME & "..." & FUNCTION & "..." to a string-variable, but that doesn't work. The reason for that are the many quotes in the command-string I guess... I don't know.
Indeed !

It's easy to solve. Use "quote"

Code: Select all

put quote & template & quote & name & quote
.... etc.

Or, you can use a wild char (for instance "$")

and then, after your query is built :

Code: Select all

replace "$" with quote in myQuery
etc.

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

Re: XML-Style Script-Command - best practise??

Post by Klaus » Mon Oct 07, 2013 12:59 pm

Hi Martin,

check this thread for some very helpful functions:
http://forums.runrev.com/phpBB2/viewtop ... +q2#p84006


Best

Klaus

HansImGlueck
Posts: 4
Joined: Thu Oct 03, 2013 9:14 am

Re: XML-Style Script-Command - best practise??

Post by HansImGlueck » Tue Oct 08, 2013 9:33 am

Thank you very much - I tried bangkok's replace-method and that work's well for my purposes.
Thank's again Klaus - I'm gonna fiddle around with your functions as well, trying to understand how they work. As I told you, I'm a noob!!

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

Re: XML-Style Script-Command - best practise??

Post by Klaus » Tue Oct 08, 2013 11:07 am

Hi Matrin,

well, my little functions just put (double resp. single) quotes around a given string, that's all.
But will save a lot of typing :D


Best

Klaus

Post Reply