Page 1 of 1

SOLVED: #PB_Menu_Quit - constant not found

Posted: Fri Aug 01, 2025 3:03 pm
by SparrowhawkMMU
Hi,

I've just installed PureBasic 6.21 on ZorinOS 17.3 (based on Ubuntu 22.04).

An old program of mine which compiles fine under macOS 15.6 (and whatever OS X version was current when I wrote this 6 years ago) fails with this error on the above Linux:

Code: Select all

[COMPILER] Line 49: Constant not found #PB_Menu_Quit.
The line in question is polling in my main event loop :

Code: Select all


; *** the includes, settings, app window opening etc are above and not shown here to keep code shorter in forum ***

; Event loop - just catch the exiting event(s)
; All other events should be module-level
Define eventNumber.i = 0

Repeat	
	
	eventNumber = WaitWindowEvent()
	
	If eventNumber = #PB_Event_Menu And EventMenu() = #PB_Menu_Quit  ; *** <= THIS IS LINE 49 ***
		PostEvent(#PB_Event_CloseWindow)
	EndIf
	
Until eventNumber = #PB_Event_CloseWindow

End

.

TBH it's been a few years since I used PB in anger, so maybe the above is not the best way to do things, but the fact that a constant seems to be missing in the Linux version is a bit of a worry.

Does anyone else have this issue or is it just me?

Thanks

Re: #PB_Menu_Quit - constant not found

Posted: Fri Aug 01, 2025 3:38 pm
by Fred

Re: #PB_Menu_Quit - constant not found

Posted: Fri Aug 01, 2025 6:36 pm
by mk-soft
Ich use a simple Compiler Directives

Template Base.pb

Code: Select all

;-TOP

#ProgramTitle = "Main Window"
#ProgramVersion = "v1.01.2"

Enumeration Windows
  #Main
EndEnumeration

Enumeration MenuBar
  #MainMenu
EndEnumeration

Enumeration MenuItems
  #MainMenuAbout
  #MainMenuExit
EndEnumeration

Enumeration Gadgets
  
EndEnumeration

Enumeration StatusBar
  #MainStatusBar
EndEnumeration

Procedure UpdateWindow()
  Protected dx, dy
  dx = WindowWidth(#Main)
  dy = WindowHeight(#Main) - StatusBarHeight(#MainStatusBar) - MenuHeight()
  ; Resize gadgets
EndProcedure

Procedure Main()
  Protected dx, dy
  
  #MainStyle = #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_MaximizeGadget | #PB_Window_MinimizeGadget
  
  If OpenWindow(#Main, #PB_Ignore, #PB_Ignore, 800, 600, #ProgramTitle , #MainStyle)
    ; Menu
    CreateMenu(#MainMenu, WindowID(#Main))
    MenuTitle("&File")
    CompilerIf #PB_Compiler_OS = #PB_OS_MacOS
      MenuItem(#PB_Menu_About, "")
    CompilerElse
      MenuItem(#MainMenuAbout, "About")
    CompilerEndIf
    ; Menu File Items
    
    CompilerIf Not #PB_Compiler_OS = #PB_OS_MacOS
      MenuBar()
      MenuItem(#MainMenuExit, "E&xit")
    CompilerEndIf
    
    ; StatusBar
    CreateStatusBar(#MainStatusBar, WindowID(#Main))
    AddStatusBarField(#PB_Ignore)
    
    ; Gadgets
    dx = WindowWidth(#Main)
    dy = WindowHeight(#Main) - StatusBarHeight(#MainStatusBar) - MenuHeight()
    
    ; Bind Events
    BindEvent(#PB_Event_SizeWindow, @UpdateWindow(), #Main)
    
    ; Event Loop
    Repeat
      Select WaitWindowEvent()
        Case #PB_Event_CloseWindow
          Select EventWindow()
            Case #Main
              Break
              
          EndSelect
          
        Case #PB_Event_Menu
          Select EventMenu()
            CompilerIf #PB_Compiler_OS = #PB_OS_MacOS   
              Case #PB_Menu_About
                PostEvent(#PB_Event_Menu, #Main, #MainMenuAbout)
                
              Case #PB_Menu_Preferences
                
              Case #PB_Menu_Quit
                PostEvent(#PB_Event_CloseWindow, #Main, #Null)
                
            CompilerEndIf
            
          Case #MainMenuAbout
            MessageRequester("About", #ProgramTitle + #LF$ + #ProgramVersion, #PB_MessageRequester_Info)
              
          Case #MainMenuExit
            PostEvent(#PB_Event_CloseWindow, #Main, #Null)
            
          EndSelect
          
        Case #PB_Event_Gadget
          Select EventGadget()
              
          EndSelect
          
      EndSelect
    ForEver
    
  EndIf
  
EndProcedure : Main()

Re: #PB_Menu_Quit - constant not found

Posted: Fri Aug 01, 2025 8:37 pm
by SparrowhawkMMU
Oh thanks, I had no idea these differed between OSes. Will look at the proposed solution above, thank you.