Method to embed semicolon in a string

Discussion of Inner Space

Moderators: Lavish Software Team, Moderators

Post Reply
mistahmikey
GamingTools Subscriber
Posts: 29
Joined: Wed Jun 30, 2010 7:48 am

Method to embed semicolon in a string

Post by mistahmikey » Wed Dec 25, 2013 12:20 pm

I wish to create a command on the fly along the lines of:

variable string Command

Command:Set[execute <command1> ; <command2>]

relay all ${Command.Escape}

but I can find no way to embed the semicolon into Command. For example, if I do the following:

Command:Set[\;]

echo ${Command.Escape}

returns

echo: <text>

It appears there is no way to escape semicolon.

So is what I am trying to do even possible (i.e, relay 2 or more commands to be execute at once). If so, how do I arrange it syntactically?

Thanks

Lax
Owner
Posts: 6634
Joined: Fri Jun 18, 2004 6:08 pm

Post by Lax » Wed Dec 25, 2013 3:21 pm

Use quotes. Quotes denote a string and removes the special behavior of various characters including comma, brackets, etc.

Command:Set[";"]

relay all "${Command.Escape}"

mistahmikey
GamingTools Subscriber
Posts: 29
Joined: Wed Jun 30, 2010 7:48 am

Post by mistahmikey » Thu Dec 26, 2013 11:00 am

For some reason, this does not work for me. So if I try the following:

variable string Command

Command:Set[";"]

echo ${Command.Escape}

I get:

Syntax: Echo <text>

When I try embedding a ; into a longer string, anything after the ; is ignored, i.e., it appears to be treating everything after the ; as a comment.

Lax
Owner
Posts: 6634
Joined: Fri Jun 18, 2004 6:08 pm

Post by Lax » Thu Dec 26, 2013 11:24 am

Because once again you need to quote to remove the behavior of the ;

Code: Select all

echo "$&#123;Command.Escape&#125;"

mistahmikey
GamingTools Subscriber
Posts: 29
Joined: Wed Jun 30, 2010 7:48 am

Post by mistahmikey » Thu Dec 26, 2013 12:23 pm

Yep, sorry about that - realized it and was going to delete the post. Thanks for your patience.

mistahmikey
GamingTools Subscriber
Posts: 29
Joined: Wed Jun 30, 2010 7:48 am

Post by mistahmikey » Thu Dec 26, 2013 1:04 pm

Well, as it turns out, I still have an issue. I am unable to get two commands to execute using the execute command. So, for example

execute "echo one ; echo two"

only outputs "one".

Ultimately, what I want is to be able to execute multiple commands using relay, like:

relay all execute "echo one ; echo two"

Is there a way to do this?

Lax
Owner
Posts: 6634
Joined: Fri Jun 18, 2004 6:08 pm

Post by Lax » Thu Dec 26, 2013 1:14 pm

The space after your semicolon is breaking the command parser.

Code: Select all

execute "echo one;echo two"
works fine

mistahmikey
GamingTools Subscriber
Posts: 29
Joined: Wed Jun 30, 2010 7:48 am

Post by mistahmikey » Thu Dec 26, 2013 1:29 pm

Aha. Got it working now. Thanks very much.

Post Reply