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

The function @if[...] doesn't work

Discussion in 'TCC/LE Support' started by EWg, Jan 16, 2012.

  1. EWg

    EWg

    Joined:
    Jan 14, 2012
    Messages:
    5
    Likes Received:
    0
    (TCC LE 13.03.38 Win7)
    I have problems with the @if function:
    echo %@if[%@eval[ %_WINVER - 6] ge 6 , this, that]
    echos "this, that" :( .
    4NT 3,02B works fine of a NT system!

    A similar problem we have with
    SWITCH %@FIELD[...]
    combinations.
     
  2. Steve Fabian

    Joined:
    May 20, 2008
    Messages:
    3,520
    Likes Received:
    4
    I pasted your test into both the full and LE versions of TCC 13.0.38 on WinXP SP3 and it worked correctly on both systems, displaying " that" (no Win6 available here). I was able to duplicate your report by defining my own @IF function: function if=`4$` - i.e., value is the 4th and all subsequent function parameters (assuming you use the 4NT/TCC default ParameterChar). Immediately I "unfunctioned" IF, and correct operation was restored.

    Your second issue does not have a testable example. Just remember, SWITCH has a SINGLE parameter which is a string. @FIELD - if you use non-default field separators - can return multiple strings, or an empty string, either of which causes SWITCH to report an error. Of course, you probably use it correctly.
     
  3. Rodolfo

    Joined:
    May 20, 2009
    Messages:
    216
    Likes Received:
    0
    I too get the same "this, that".
    It might depend on the what is used as "comma".
    On my system, one thousand is written "1.000,00".
    So: "%_WINVER" is "5,2"; "%@eval[%_WINVER - 6]" is "-0,8".
    And it is possible that the comma between 0 and 8 is considered as an argument separator.
    If I write "echo %@if[%@eval[0,8] ge 6, this, that]" I get " this, that".
    If I write "echo %@if[%@eval[0.8] ge 6, this, that]" I get " this".

    Regards

    Rodolfo Giovanninetti
     
  4. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    10,040
    Likes Received:
    84
    WAD. You're inserting additional separator characters; there's no way that @IF can predict what is an embedded "ignore-this-it's-not-really-a-delimiter" character and what is a "wait-this-is-really-a-delimiter" character (unless you quote the non-delimiter characters). You need to switch to the DWIM parser!

    There aren't many cases where you actually *have* to use @IF instead of IFF / THEN / ELSE.
     
  5. EWg

    EWg

    Joined:
    Jan 14, 2012
    Messages:
    5
    Likes Received:
    0
    (TCC LE 13.03.39 WinXP I've updated my TCC LE )
    I found a solution for my problem using "%@int[%_WINVER] ge 6"...
    But the SWITCH is still annoying.
    :See uploaded file "test.btm"
     

    Attached Files:

  6. Stefano Piccardi

    Joined:
    May 31, 2008
    Messages:
    376
    Likes Received:
    2
    If you want something truly portable across locales use, %@word[",.",0,%_winver] ge 6
    Code:
    C:>setdos /G, & echo %@word[".,",0,%_winver] %@int[%_winver] & setdos /G.
    6 6,1
     
    C:>setdos /G. & echo %@word[".,",0,%_winver] %@int[%_winver] & setdos /G.
    6 6
    
     

Share This Page