Escape of brackets in speedwalk string

Posted by Jcl2016 on Fri 23 Dec 2016 06:37 AM — 4 posts, 15,958 views.

#0
According to the document, we can use non-standard directions or general commands in speedwalk by putting them in brackets. For example: #3(say hello)

I want to know whether there is a escape character, so we can use commands containing brackets?
For example, I want to evaluate "say (hello)" command in speedwalk, "#3(say (hello))" is invalid, and "#3(say \(hello\))" is invalid too.
Is there a way to do this?
Australia Forum Administrator #1
Is this for using speedwalks as a command? Or in a script?

If you are just typing something in, like:


#3(say (hello))


You can always make an alias that matches on "#*" and then make your own rules for evaluation of what follows. It doesn't look as if the inbuilt rules allow for what you have in mind.
#2
Nick Gammon said:

Is this for using speedwalks as a command? Or in a script?

If you are just typing something in, like:


#3(say (hello))


You can always make an alias that matches on "#*" and then make your own rules for evaluation of what follows. It doesn't look as if the inbuilt rules allow for what you have in mind.


I use it in a script. The command is not just repeat someting. For example, I will use it like this:
#3n2e(ne/sw)3(turn left)3(turn right)(enter/out)

In most cases, the speedwalks have no problem.
But there are some special scenarios where commands will contain brackets, so the speedwalks will be broken.

Now I'm using server side alias to avoid the commands containing brackets. But the server side alias can't be too much. So I want to know whether there is client side solution.
Australia Forum Administrator #3
In a script you could always do part of the speed walk, send the next bit, and then do the next part. eg.


Queue (EvaluateSpeedwalk("4n"), true)
Queue ("say (hello)", true)
Queue (EvaluateSpeedwalk("3n2e(ne/sw)3(turn left)3(turn right)"), true)


Or you could choose some replacement characters (eg. "[" and "]") and then fix them up, eg.


sw = "4n3n2e(ne/sw)(say [hello])3(turn left)3(turn right)"
evaluated = EvaluateSpeedwalk(sw, true)
-- turn square brackets into round brackets, queue the speedwalk
Queue (string.gsub (evaluated, "[%[%]]", { ["["] = "(", ["]"] = ")" } ))