Announcement

Collapse
No announcement yet.

Simple macro does not replace well?

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

  • Simple macro does not replace well?

    I have this macro:

    Macro hello = EnableWindow

    And i try to use it like this:
    Code:
        Local hWnd As Long
        hWnd = GetDlgItem( nCbHndl, %ID_FORM1_BUTTON1 )
        hello hWnd, 0
        hello( hWnd, 0 )
    hWnd is the control's hwnd and only the firest hello is accepted by the compiler (8.04).
    The 2nd gives me:

    Mismatch with prior definition
    Line 8: hello( hWnd, 0 )

    In my opinion both should work??
    hellobasic

  • #2
    Hi Edwin,

    it is a bid odd.
    To make it work with parenthesis you can go for:
    Code:
    MACRO hello( par1, par2 ) = EnableWindow( par1, par2 )
    ... but this way it won't work without parenthesis
    So maybe better to simply stick with one convention.

    I thought PB MACROs simply seek & replace, but it seems they do something more.


    Petr
    [email protected]

    Comment


    • #3
      Needs space between "hello" and "(" ???
      Michael Mattias
      Tal Systems (retired)
      Port Washington WI USA
      [email protected]
      http://www.talsystems.com

      Comment


      • #4
        I tried already
        hellobasic

        Comment


        • #5
          This might sound silly Edwin, but have you checked your DECLARE for EnableWindow()?

          i.e, it is remotely possible the '480' error message actually means it this time.
          Michael Mattias
          Tal Systems (retired)
          Port Washington WI USA
          [email protected]
          http://www.talsystems.com

          Comment


          • #6
            Does it work for you?
            It is a simple matter to test like:

            #include "win32api.inc"

            MACRO hello = EnableWindow

            pbmain...
            if 0 = 1 then
            hello( 0, 0 )

            end if

            ?
            hellobasic

            Comment


            • #7
              Originally posted by Edwin Knoppert View Post
              Does it work for you?
              I don't know the reason for sure, but when I first encountered it, I assumed that the macro definition has a special case for "no arguments", and has thus identified the macro as one which takes no arguments. However, this is not consistent with the macro passing compilation if the arguments are parenthesised.

              I suggest that you drop a line to PowerBasic about this one.

              Comment


              • #8
                At the risk of sticking my neck out and feeling the wrath of MM:-
                hello hWnd, 0 on its own is OK, but is it not something=hello( hWnd, 0 )?

                Expecting to get flamed on this

                Iain Johnstone
                “None but those who have experienced them can conceive of the enticements of science” - Mary Shelley

                Comment


                • #9
                  For now i used the parameters as suggested.
                  Though i wanted to make an alias for an existing function, not this but similar.
                  hellobasic

                  Comment


                  • #10
                    >Does it work for you?

                    I do not have same version of compiler in use, but I get the same error in PB/Win 8.03
                    Code:
                    hello (0,0) ==> 480 parameter mismatch
                    hello  0,0   ==> compiles OK
                    a = hello (0,0)  ==> 480 parameter mismatch
                    I think I know the problem: when you use the parens, it's ambiguous as to what the parens mean: Do these parens delimit MACRO tokens and should be used at substitution time or are they part of what should follow after MACRO substitution?

                    Workaround: Instead of MACRO, use DWIMMACRO ( Do What I Mean MACRO)

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

                    Comment


                    • #11
                      >Workaround: Instead of MACRO, use DWIMMACRO ( Do What I Mean MACRO)

                      Huh?
                      hellobasic

                      Comment


                      • #12
                        Oh, that's right, DWIMMACRO is in 8.03. They must have removed it in 8.04.

                        (I knew there was a reason I didn't upgrade right away!)

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

                        Comment


                        • #13
                          Originally posted by Edwin Knoppert View Post
                          >Workaround: Instead of MACRO, use DWIMMACRO ( Do What I Mean MACRO)

                          Huh?

                          It's a joke. No such thing.
                          Do not go quiet into that good night,
                          ... Rage, rage against the dark.

                          Comment

                          Working...
                          X