Announcement

Collapse
No announcement yet.

Backward incompatibility?

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

  • Backward incompatibility?

    Compiles In PBWin 8 but Not In PBWin 9
    Error 543 - Must be outside Sub/Function

    '
    Code:
    #Compile Exe  
    #Include "WIN32API.INC"
    Sub test_Include 
        %Top = %MB_TASKMODAL 'keep for older msgbox msgs  
    End Sub
    Function PBMain
      Call test_Include
      ? "Worked"
    End Function
    '
    It's a pretty day. I hope you enjoy it.

    Gösta

    JWAM: (Quit Smoking): http://www.SwedesDock.com/smoking
    LDN - A Miracle Drug: http://www.SwedesDock.com/LDN/

  • #2
    Yes it's a new restriction due to the forward-referencing feature.
    Simply move the constant(s) outside of a FUNCTION or SUB and the code will compile fine.
    kgpsoftware.com | Slam DBMS | PrpT Control | Other Downloads | Contact Me

    Comment


    • #3
      Looks like only subs/functions can be forward referenced, right? I tried a quick test to see if equates and types could be forward referenced and I don't think they can. They need to be defined prior to being referenced. Am I correct in saying that?
      Paul Squires
      FireFly Visual Designer (for PowerBASIC Windows 10+)
      Version 3 now available.
      http://www.planetsquires.com

      Comment


      • #4
        Yes.
        Forum: http://www.jose.it-berater.org/smfforum/index.php

        Comment


        • #5
          They need to be defined prior to being referenced.
          They can now be redefined prior to being used.
          Rod
          I want not 'not', not Knot, not Knott, not Nott, not knot, not naught, not nought, but aught.

          Comment


          • #6
            Just to be clear the help file notes (What's New, Additional Changes), an equate (constant) that can be re-defined before use is one "which is pre-defined in the compiler"

            Here's the complete change remark:
            Any numeric equate or string equate which is pre-defined in the compiler may be assigned a revised value if the new assignment is performed before the equate is referenced in the program
            Last edited by Richard Angell; 29 Aug 2008, 01:24 PM. Reason: ADDED EMPHASIS ...
            Rick Angell

            Comment


            • #7
              I would consider a slight language rewrite as follows:

              The value of any numeric equate or string equate which is pre-defined in the compiler may overridden if the new assignment is performed before the equate is referenced in the program
              <b>George W. Bleck</b>
              <img src='http://www.blecktech.com/myemail.gif'>

              Comment


              • #8
                which is pre-defined in the compiler
                Who put that there?
                Well, that's only my second mistake, first since 1962.

                Glad somebody caught it.
                Last edited by Rodney Hicks; 29 Aug 2008, 08:19 PM. Reason: add to
                Rod
                I want not 'not', not Knot, not Knott, not Nott, not knot, not naught, not nought, but aught.

                Comment


                • #9
                  It's just as well that that it's only pre-defined constants. Otherwise you could inadvertently redefine some equate you forgot you had used and buried deep down in some #INCLUDE file.

                  That's why I use #IF %DEF(%equate_name) a lot. Very handy.

                  Still waiting (apparently) for support for '%Def (procedure_name)' but setting my own equates and using %DEF(%equate_meaning_procedure_name_is_defined) works OK.

                  #UNDEF and/or #REDEF would still be useful.

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

                  Comment


                  • #10
                    delete
                    Last edited by Dale Yarker; 30 Aug 2008, 11:29 AM.
                    Dale

                    Comment

                    Working...
                    X