Page 1 of 1

XML-Style Script-Command - best practise??

Posted: Mon Oct 07, 2013 12:12 pm
by HansImGlueck
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

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

Posted: Mon Oct 07, 2013 12:23 pm
by bangkok
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.

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

Posted: Mon Oct 07, 2013 12:59 pm
by Klaus
Hi Martin,

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


Best

Klaus

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

Posted: Tue Oct 08, 2013 9:33 am
by HansImGlueck
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!!

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

Posted: Tue Oct 08, 2013 11:07 am
by Klaus
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