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

if and text: bug or feature?

Discussion in 'Support' started by Péter Köves, Feb 1, 2009.

  1. Péter Köves

    Joined:
    Jun 1, 2008
    Messages:
    58
    Likes Received:
    0
    This
    iff cond then
    text
    ...
    endtext
    endiff

    works as expected.
    But this
    if cond text
    ...
    endtext

    works fine if the condition is true. If it is false, then things go haywire and as far as I can tell subsequent batch lines are swallowed (not executed) until a return (this was in a subroutine).
     
  2. rconn

    rconn Administrator
    Staff Member

    Joined:
    May 14, 2008
    Messages:
    9,732
    Likes Received:
    81
    WAD - and you *really* wouldn't want it to work any other way.

    If an IF condition fails, IF will not execute the command, so the parser has
    no way to know that you're trying to use a TEXT / ENDTEXT. The only way it
    could know that would be to expand and execute the command in every
    instance, which would render the IF moot! :-)

    Bottom line - never, never, put a TEXT / ENDTEXT in an IF statement.

    Rex Conn
    JP Software
     
  3. Péter Köves

    Joined:
    Jun 1, 2008
    Messages:
    58
    Likes Received:
    0
    You may want to add a warning to the documentation of IF. I figured out what was going on but it took a while. Once I understood, I also had a good idea of what your response would be ;) too.

    It just bugs me if there are exceptions to general rules (in my old age strike that... mature years I have trouble remembering them) and especially undocumented ones.
     

Share This Page