1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to escape?

Discussion in 'Support' started by jbanaszczyk, Oct 18, 2014.

  1. jbanaszczyk

    Joined:
    Jun 8, 2013
    Messages:
    98
    Likes Received:
    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?
     
  2. vefatica

    Joined:
    May 20, 2008
    Messages:
    8,075
    Likes Received:
    30
    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 ]--
     
  3. jbanaszczyk

    Joined:
    Jun 8, 2013
    Messages:
    98
    Likes Received:
    0
    So simple. Thanks.
     

Share This Page