Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

How to escape?

Jun
98
0
Hello. A small trouble.

I want to show something in color.
Like that
Code:
*Set title=something
*Echo --( %@If[%_ansi==1,^e[1;33m,]%[title]%@If[%_ansi==1,^e[0m,] )--
It works fine, doesn't matter if ANSI is enabled or not.

Now let's replace brackets ( ) -> [ ]
Code:
*Set title=something
*Echo --[ %@If[%_ansi==1,^e[1;33m,]%[title]%@If[%_ansi==1,^e[0m,] ]--

Last, closing brace ']' is interpreted as closing bracket of %@If[ ]
Of course, I can use extra variables, containing values of %@If[]'s.

How should it be written in one working line?
 
Just escape the '[' characters in the ANSI sequences.
Code:
v:\> set title=foo

v:\> Echo --[ %@If[%_ansi==1,^e^[1;32m,]%[title]%@If[%_ansi==1,^e^[0m,] ]--
--[ foo ]--
 
Back
Top