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

command line parsing question

Discussion in 'Support' started by HSaathoff, Jul 21, 2015.

  1. HSaathoff

    Joined:
    Jul 21, 2015
    Messages:
    4
    Likes Received:
    0
    Hallo,
    in a batch file I wanted to show some messages and found a strange behaviour in the output of an echo command. This echo command
    echo At %_TIME: T=%_TRANSIENT
    displayed
    At 14:55:39_TRANSIENT
    Without the colon after %_TIME I got the expected
    At 14:57:38 T=0

    What does the colon do in the echo?
    BTW, entering a blank before : does also cure the effect.

    This happens with TCC 15.00.33

    - Heinz Saathoff
     
  2. Rodolfo

    Joined:
    May 20, 2009
    Messages:
    213
    Likes Received:
    0
    I believe that You hit the syntax for text replacement.
    At http://ss64.com/nt/syntax-replace.html You can find more information.

    Regards

    Rodolfo Giovanninetti
     
  3. samintz

    samintz Scott Mintz

    Joined:
    May 20, 2008
    Messages:
    1,188
    Likes Received:
    11
    Yes. That is CMD.EXE's syntax for string substitution. You can work around it in TCC by enclosing the variable in []'s:
    Code:
    echo %[_TIME]: T=%_TRANSIENT
    
     
  4. dcantor

    Joined:
    May 29, 2008
    Messages:
    507
    Likes Received:
    3
    Or by supplying a trailing % after the variable:
    Code:
    echo %_TIME%: T=%_TRANSIENT
     
  5. HSaathoff

    Joined:
    Jul 21, 2015
    Messages:
    4
    Likes Received:
    0
    That makes sense. Didn't think of such a weird functionality :smile:


    - Heinz Saathoff
     
  6. Alpengreis

    Joined:
    Jan 12, 2014
    Messages:
    228
    Likes Received:
    6
    Escape the colon. I have defined the "^" as escape char ...

    echo At %_TIME^: T=%_TRANSIENT
     

Share This Page