Announcement

Collapse
No announcement yet.

565 error - Macro mismatch with code position

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

  • 565 error - Macro mismatch with code position

    When C&P's some macros from an include file to a program, I kept getting

    "565 error - Macro mismatch with code position -" errors.

    I've seen that a couple times before and if I just moved things around a little the 565 seemed to go away but that doesn't work here no matter where I put them. (Note the Macros run fine in other programs.)

    I found this:

    http://www.powerbasic.com/support/pb...+code+position

    Anybody have any other ideas? I looked at the "offenders" in hex but don't see any rogue characters.


    ============================================================
    "Women might be able to fake orgasms.
    But men can fake a whole relationship."
    Sharon Stone
    ============================================================
    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
    I think I'd probably first look at the source code to see if there's a problem.

    Bob Zale
    PowerBASIC Inc.

    Comment


    • #3
      One thing, you may want to check to see if you're declaring the same MACRO twice. I've seen the error in that situation.

      Comment


      • #4
        Bob,

        I will do that again. Several (more actually) haven't turned up anything. It will probably be a week or before I can report back though. I've worked around the problem for now though.

        John,

        I don'think that's the case. Usually when that happens, both macros will show in the Function List window (JF Pro). I tried remming all the m's then unremming one at a time but the error kept occurring. I'll give it another shot though.

        Thanks replies guys.

        =================================
        "Silence is argument
        carried out by other means."
        Ernesto"Che"Guevara (1928-1967)
        =================================
        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/

        Comment


        • #5
          This is not a duplicate macro definition. This is not a matter of "moving things around a little".

          This is a matter of misusing a particular style of macro. Like referencing a MULTI-LINE MACRO as a term in a numeric expression (That's equivalent to "x& = PRINT * y&). Or referencing a FUNCTION MACRO in a statement position (the first and only item in a line of code "HEX$(i&)").

          If you just post the code for the macro, and the line of code which uses it, someone will be able to see the problem. Without showing the code, it's pretty difficult to help.

          Best regards,

          Bob Zale
          PowerBASIC Inc.

          Comment


          • #6
            Here's the code I tried to insert into an existing program (that runs fine) and yielded the 565.

            Code:
            '""""""""""" MsgBox Macros """"""""""""""""""""""""""""""""
            Macro mb_Locals 'to use in programs without Common_Locals
              Local m$, m1$, m2$, m3$, m4$, m5$, m6$, m7$, m8$, m9$, m10$
              Local ans&, MB_Style&
            End Macro
            ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
             
            Macro mb_Msgbox   
              MsgBox m$ & $CrLf & _
                     m1$ & $CrLf & _
                     m2$ & $CrLf & _
                     m3$ & $CrLf & _
                     m4$ & $CrLf & _
                     m5$ & $CrLf & _
                     m6$ & $CrLf & _
                     m7$ & $CrLf & _
                     m8$ & $CrLf & _
                     m9$ & $CrLf & _
                     m10$, _
                     %MB_OK Or %MB_SYSTEMMODAL Or mb_Style, _
                    " In " & FuncName$ 
              Reset m$, m1$, m2$, m3$, m4$, m5$, m6$, m7$, m8$, m9$, m10$
            End Macro      
            '
            Macro mb = mb_Msgbox
            '
            Macro m_Err_Msg 
             If Err Then 
                mb_Style = %MB_ICONERROR: mb_Msgbox  
             End If                
            End Macro 
            '                
            Macro mb_Question =  mb_Style = %MB_ICONQUESTION: Mb_MsgBox                   
            '
            Macro mb_Stop = mb_Style = %MB_ICONERROR: mb_Msgbox
            '
            Macro mb_Alert = mb_Style = %MB_ICONWARNING: mb_Msgbox
            '
            Macro mb_ans 
            ' m$ = "Do you REALLY want to erase everything?"
            ' m1$ = 
            ' mb_ans
            '  If ans = %IdYes Then             
            '     '
            '  End If
                m$ = m$ & $CrLf & _ 
                     m1$ & $CrLf & _
                     m2$ & $CrLf & _
                     m3$ & $CrLf & _
                     m4$ & $CrLf & _
                     m5$ & $CrLf & _
                     m6$ & $CrLf & _
                     m7$ & $CrLf & _
                     m8$ & $CrLf & _
                     m9$ & $CrLf & _
                     m10$
              Ans = MsgBox(m$, _
                           %MB_TASKMODAL Or %MB_YESNO, _
                           " in " & FuncName$)
              Reset m$, m1$, m2$, m3$, m4$, m5$, m6$, m7$, m8$, m9$, m10$
            End Macro
            '
            '''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
            The program I tried to insert this into has no Macros, Subs or Functions of the same name(s). However, writing this it occurs to me there may be some same named variables. I don't think that should be a problem as I think the compiler would alert the same variable has been declared twice. (2 Locals, or Global & Local in same routine.)

            When I said I had had the 565 before and fixed it by "moving things around a little", that was just recollection. It may well be it was not a 565 but a similar msg. I didn't write down the err msg..

            Also there was no resolution in the above mentioned thread. Both posters in that thread are experienced PB'ers (far more than I) so I just figured it was "one of those things".

            ============================================================
            Why worry about martial law when
            there is pork to be harvested
            and photo ops to attend?"
            Joe Byrne
            ============================================================
            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/

            Comment


            • #7
              Gosta,
              Code:
              MACRO mb_Msgbox
                m10$=" In " & FUNCNAME$  
                MSGBOX m$ & $CRLF & _
                       m1$ & $CRLF & _
                       m2$ & $CRLF & _
                       m3$ & $CRLF & _
                       m4$ & $CRLF & _
                       m5$ & $CRLF & _
                       m6$ & $CRLF & _
                       m7$ & $CRLF & _
                       m8$ & $CRLF & _
                       m9$ & $CRLF & _
                       m10$, _
                       %MB_OK OR %MB_SYSTEMMODAL OR mb_Style                ', _
                                                                                                                                       '& " In " & FUNCNAME$
                RESET m$, m1$, m2$, m3$, m4$, m5$, m6$, m7$, m8$, m9$, m10$
              END MACRO
              Try it this way.
              Rod
              Rod
              In some future era, dark matter and dark energy will only be found in Astronomy's Dark Ages.

              Comment


              • #8
                I tried this way and got error 415 "=" expected with the mb macro in PBMain
                Code:
                MACRO mb_Msgbox
                  
                   m10$=" In " & FUNCNAME$
                  MSGBOX m$ & $CRLF & _
                         m1$ & $CRLF & _
                         m2$ & $CRLF & _
                         m3$ & $CRLF & _
                         m4$ & $CRLF & _
                         m5$ & $CRLF & _
                         m6$ & $CRLF & _
                         m7$ & $CRLF & _
                         m8$ & $CRLF & _
                         m9$ & $CRLF,
                        
                         %MB_OK OR %MB_SYSTEMMODAL OR mb_Style, _
                         m10$
                  RESET m$, m1$, m2$, m3$, m4$, m5$, m6$, m7$, m8$, m9$, m10$
                END MACRO
                Fooling around with this leads me to believe that for some reason it doesn't want any parameters (title$)after whatever styles used.
                Rod
                Last edited by Rodney Hicks; 22 Mar 2008, 04:58 PM. Reason: correcting syntax?
                Rod
                In some future era, dark matter and dark energy will only be found in Astronomy's Dark Ages.

                Comment


                • #9
                  tried this way and got error 415 "=" expected with the mb macro in PBMain
                  It's because the compiler is thinking you want to define a constant when you include it on the line like that (hence the "=" required - to assign a value), moving the line up and placing an underscore "_" after the last "$CRLF, " part and it will compile correctly.

                  Code:
                   
                  Macro mb_Msgbox
                  m10$=" In " & FuncName$
                  MsgBox m$ & $CrLf & _
                  m1$ & $CrLf & _
                  m2$ & $CrLf & _
                  m3$ & $CrLf & _
                  m4$ & $CrLf & _
                  m5$ & $CrLf & _
                  m6$ & $CrLf & _
                  m7$ & $CrLf & _
                  m8$ & $CrLf & _
                  m9$ & $CrLf, _
                  %MB_OK Or %MB_SYSTEMMODAL Or mb_Style, _
                  m10$
                  Reset m$, m1$, m2$, m3$, m4$, m5$, m6$, m7$, m8$, m9$, m10$
                   
                  End Macro
                  kgpsoftware.com | Slam DBMS | PrpT Control | Other Downloads | Contact Me

                  Comment


                  • #10
                    Gosta--

                    As I said before, the problem is not in the macro. It's in the position where you referenced it.

                    If you want to solve the problem, you need to post both halves of the code.

                    Best regards,

                    Bob Zale
                    PowerBASIC Inc.

                    Comment


                    • #11
                      Dumb is Dumb

                      Bob,

                      This is the top of the program, up to the point where the coding starts ....

                      ...

                      Hey wait a minute. Just looked closer at what I was going to post (all lines from #Compile leading up to the first Sub/Function) and ... Son of a ***** ... (pardon me but that's EXACTLY what popped into my head). The is an old program. One of the first I had written in PB (a DOS checkbook program I had used forever, data goes back to '85).

                      What I tried to do now insert the MsgBox Macros after I had already "Included" them in. I must inserted the Include file last year (only use the prog a few times a year for tax time) before the MB macros were written. The MB's are so handy I wanted them here but they wouldn't run here (old program, Globals, Locals, Contants, ... Confusion, Old Code, New Code, Skill Levels, increasing Complexity, ... You all know the story.)

                      Boy, dumb is dumb.

                      Mea Culpa


                      ============================================================
                      "If you want to make an apple pie from scratch,
                      you must first create the universe."
                      Carl Sagan
                      ============================================================
                      Last edited by Gösta H. Lovgren-2; 22 Mar 2008, 08:38 PM. Reason: Articulation
                      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/

                      Comment


                      • #12
                        You mean I spent time trying to solve this problem, learning new things for nothing?
                        Thanks Kev. As soon as I saw what you did to the code it made sense.
                        Rod
                        Rod
                        In some future era, dark matter and dark energy will only be found in Astronomy's Dark Ages.

                        Comment


                        • #13
                          Here's a compileable example. (Note the Macro now contains a Header (m0$) that the code above does not.)

                          '
                          Code:
                          #Compile Exe  
                          #Include "WIN32API.INC"
                           
                          ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''   
                          '""""""""""" MsgBox Macros """"""""""""""""""""""""""""""""
                          Macro mb_Locals 'to use in Subs, Functions without Common_Locals
                            Local m$, m0$, m1$, m2$, m3$, m4$, m5$, m6$, m7$, m8$, m9$, m10$
                            Local ans&, MB_Style&
                          End Macro
                          ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
                          Macro mb_Msgbox   
                            If m0$ = "" Then m0$ = FuncName$ 'header
                            MsgBox m$ & $CrLf & _
                                   m1$ & $CrLf & _
                                   m2$ & $CrLf & _
                                   m3$ & $CrLf & _
                                   m4$ & $CrLf & _
                                   m5$ & $CrLf & _
                                   m6$ & $CrLf & _
                                   m7$ & $CrLf & _
                                   m8$ & $CrLf & _
                                   m9$ & $CrLf & _
                                   m10$, _
                                 %MB_OK Or %MB_SYSTEMMODAL Or mb_Style, _
                                  m0$ 
                            Reset m$, m0$,m1$, m2$, m3$, m4$, m5$, m6$, m7$, m8$, m9$, m10$
                          End Macro      
                          '
                          Macro mb = mb_Msgbox
                          '
                          Macro m_Err_Msg 
                           If Err Then 
                              mb_Style = %MB_ICONERROR: mb_Msgbox  
                           End If                
                          End Macro 
                          '                
                          Macro mb_Question =  mb_Style = %MB_ICONQUESTION: Mb_MsgBox                   
                          '
                          Macro mb_Stop = mb_Style = %MB_ICONERROR: mb_Msgbox
                          '
                          Macro mb_Alert = mb_Style = %MB_ICONWARNING: mb_Msgbox
                          '
                          Macro mb_ans 
                          ' m$ = "Do you REALLY want to erase everything?"
                          ' m1$ = 
                          ' mb_ans
                          '  If ans = %IdYes Then             
                          '     '
                          '  End If
                              If m0$ = "" Then m0$ = FuncName$ 'header
                              m$ = m$ & $CrLf & _ 
                                   m1$ & $CrLf & _
                                   m2$ & $CrLf & _
                                   m3$ & $CrLf & _
                                   m4$ & $CrLf & _
                                   m5$ & $CrLf & _
                                   m6$ & $CrLf & _
                                   m7$ & $CrLf & _
                                   m8$ & $CrLf & _
                                   m9$ & $CrLf & _
                                   m10$
                            Ans = MsgBox(m$, _
                                         %MB_TASKMODAL Or %MB_YESNO, _
                                         m0$)
                            Reset m$, m1$, m2$, m3$, m4$, m5$, m6$, m7$, m8$, m9$, m10$
                          End Macro
                          '
                           
                           
                          '****************************************************************************
                          Sub Message_Box_Examples
                            mb_Locals
                            Local x&                       
                            x = 123 * 456
                            m$ = "First line"
                            m2$ = Using$("Variable X = #, ", x )
                            mb 'call msgbox
                            
                            m0$ =        "Use M0$ for Header"
                            m2$ = Using$("Variable X = #, ", x )
                            m5$ = Using$("Variable X = #, ", x \ 23)
                            mb_Alert 'Alert
                            
                            m0$ = "STOP STOP STOP!!!"
                            m2$ = Using$("Variable X = #, ", x * 123)
                            m5$ = Using$("Variable X = #, ", x \ 231)
                            mb_Stop 
                                                       
                            m0$ = "Hey Buddy"
                            m1$ = "Can you spare a dime?"
                            m3$ = "No?"
                            m5$ = "How about a buck?"
                            m7$ = "No?"
                            m9$ = "Okay then gimme your watch or your life"
                            mb_Ans 
                                                       
                                                       
                          End Sub
                           
                          Function PBMain
                           Call Message_Box_Examples
                          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/

                          Comment


                          • #14
                            Originally posted by John Gleason View Post
                            One thing, you may want to check to see if you're declaring the same MACRO twice. I've seen the error in that situation.
                            Originally posted by Gösta H. Lovgren-2
                            What I tried to do now insert the MsgBox Macros after I had already "Included" them in.

                            Comment


                            • #15
                              Gloating, while pleasurable, is not an attractive quality John. {just kidding}
                              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/

                              Comment


                              • #16
                                >>not an attractive quality That's a funny one. I was just kidding too--thought you'd get a kick out of it.

                                Comment


                                • #17
                                  Msgbox Macros Demo

                                  Just posted a demo (Note to M. It compiles and everything.)

                                  http://www.powerbasic.com/support/pb...927#post279927

                                  >>not an attractive quality That's a funny one. I was just kidding too--thought you'd get a kick out of it.
                                  I got kicked all right.

                                  ============================================
                                  "Being with a woman all night
                                  never hurt no professional baseball player.
                                  It's staying up all night
                                  looking for a woman that does him in."
                                  Casey Stengel
                                  ============================================
                                  Last edited by Gösta H. Lovgren-2; 24 Mar 2008, 12:25 AM. Reason: Note to the netherworld.
                                  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/

                                  Comment

                                  Working...
                                  X