Announcement

Collapse
No announcement yet.

Does help file on #IF leave something out?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Does help file on #IF leave something out?

    I realize there is probably something obvious staring me
    in the face, but I just don't see it.
    I've just added a conditional (#IF) to my
    source code, and just get a
    Syntax Error 477. (Syntax error - Something is incorrect on the line
    --the compiler could not determine a proper error message.)
    The code is
    Code:
    %WIN9x=1
    #IF (%WIN9x=1) THEN
        #INCLUDE "SERVICE.INC"   ' For Win 95,98,ME
    #ELSE
        #INCLUDE "SERVNT.INC"   ' For Win NT,2k
    #ENDIF
    The error appears on the '#IF (%WIN9x=1) THEN'
    statment, and triggers even if switched to
    #IF (%WIN9x=1)
    #IF %WIN9x THEN
    or
    #IF %WIN9x

    Seems pretty simple. So does anyone see the problem?

    ------------------
    Michael Burns
    http://www.revise.com
    Michael Burns

  • #2
    The #IF metastatement does not require (or allow) the use of THEN, and it does not currently support expressions that contain an equal sign.

    The last line of code in your message should work fine...

    Code:
    %WIN9x = 1
     
    #IF %WIN9X
        'compile this code
    #ENDIF
    As far as the Help File leaving something out, the use of THEN isn't part of the syntax that is shown, and it describes the use of #IF where "equate is a named constant or constant value." Using %WIN9x+1 would qualify as a "constant value", but %WIN9x=1 does not. It is an expression.

    -- Eric

    ------------------
    Perfect Sync: Perfect Sync Development Tools
    Email: mailto:[email protected][email protected]</A>



    [This message has been edited by Eric Pearson (edited November 26, 2000).]
    "Not my circus, not my monkeys."

    Comment


    • #3
      Thanks. I tried adding the THEN after seeing some examples with it in the forums. It is possible I misqueued and saw that in discussions of PB versins other than PB DLL 6.0

      ------------------
      Michael Burns
      http://www.revise.com
      Michael Burns

      Comment


      • #4
        Instead of allowing equals signs, the #IFDEF operator can be used.

        As far as the compiler "not currently" supporting an equals sign, I doubt it ever will, since the object of an #IF must be an equate, which does not change value within a program too often.

        MCM


        ------------------
        Michael Mattias
        Racine WI USA
        [email protected]
        Michael Mattias
        Tal Systems (retired)
        Port Washington WI USA
        [email protected]
        http://www.talsystems.com

        Comment


        • #5
          Michael, that should read %DEF() rather than #IFDEF.

          #IF also supports the NOT operator, so true/false directives can be used:
          Code:
          %DEBUG = -1
          #IF NOT %DEBUG
            ...release code goes here
          #ELSE
            ...debug code goes here
          #ENDIF
          ------------------
          Lance
          PowerBASIC Support
          mailto:[email protected][email protected]</A>
          Lance
          mailto:[email protected]

          Comment


          • #6
            Expressions would be useful, here is one example:

            %version=4

            #if %version >= 4
            'Include version 4 (pro version) enhancements
            #elseif %version = 3
            'Include version 3 (standard version) enhancements
            #else
            'Include version 1,2 (beta, demo) enhancements only
            #endif


            With current system, it is only slightly cumbersome:

            %version1=-1
            %version2=-1
            %version3=-1
            %version4=-1

            #if %version4
            'Include version 4 enhancements
            #elseif %version3
            'Include version 3 enhancements
            #else
            'Include version 1 and 2 enhancements
            #endif

            I believe the former is more readable and easier to setup.

            John Kovacich

            ------------------
            Thanks,

            John Kovacich
            Ivory Tower Software

            Comment


            • #7
              I *think* that is already on the "wish list", but I'll pass the request along to be sure.


              ------------------
              Lance
              PowerBASIC Support
              mailto:[email protected][email protected]</A>
              Lance
              mailto:[email protected]

              Comment

              Working...
              X