Page 1 of 1

PureBasic quit unexpectedly

Posted: Sat Jan 01, 2022 1:43 am
by Distorted Pixel
Hi,

My images aren't loading here to show, maybe I should use my other cloud service, but below are word explanations of what is happening. If someone needs me to show the images I can upload them to my other cloud service and maybe they will show here.

I am new to Mac OS X programming, I'm a PC programmer, but I'm trying to expand my programs to multiple devices. I have 5.73 LTS version on my MacBook Air running Monteray 12.1. Hard drive is small so I have a 2TB external SSD connected. I keep getting the following things happening when I start PureBasic up and quit after I save everything.

I get this when I start PureBasic up the next time after I have saved a project during the previous time
"A previous IDE session seems to have ended improperly"
It gives me the opportunity to open a session if I want to save, but it won't do anything after you select any session listed.

This is what I get after I save the project and exit PureBasic
"A Problem Report for PureBasic" is what is says at the top of a generated report and at the bottom I have the option to click "Ok" or "ReOpen"

How can I resolve this or can someone help me make sure PureBasic is setup right?
The debbuger also tells me my images don't exist when they do. I believe I have the path corrent in the program

Re: PureBasic quit unexpectedly

Posted: Sat Jan 01, 2022 2:15 am
by mk-soft
This is a known bug that should be fixed in the next version.

Current solutions:
1. Switch off the history under settings

2. Replace the IDE in PureBasic.app with a repaired version from me.

Go to the app with the right mouse button and display the package content. The programme is stored under PureBasic.app/Contents/MacOS.

Download Link: My Cloud OneDrive

---
The debbuger also tells me my images don't exist when they do. I believe I have the path corrent in the program
For this we need some code. With macOS, the path is a little different than with windows.

Re: PureBasic quit unexpectedly

Posted: Sat Jan 01, 2022 5:55 am
by Distorted Pixel
For this we need some code. With macOS, the path is a little different than with windows./quote]

Thank you, I think the IDE replacement helped. I changed the history setting too
I don't have anything inside the Repeat Until loop yet.

[img]https://mega.nz/file/I5dmgR5A#5UMWKqg45 ... -kCRfI/img]

Code: Select all

Procedure PlayerNumberSelection()
    
  If OpenWindow(0, 0, 0, 1440, 810, "")
    ImgFile = LoadImage(#PB_Any,"/Volumes/untitled 1/PureBasic Projects/ Ultimate Football Manager/Media/football1.png")
    Window = OpenWindow(#PB_Any, x, y, 1440, 810, "", #PB_Window_BorderLess)
    ImageGadget(#PB_Any, 0, 0, 1440, 810, ImageID(ImgFile))
    
   Repeat
      Event = WaitWindowEvent()
      
      
    Until Event = #PB_Event_CloseWindow 
      
  EndIf
   
 EndProcedure/code]

Re: PureBasic quit unexpectedly

Posted: Sat Jan 01, 2022 12:24 pm
by mk-soft
Check your path with

Code: Select all

path.s = OpenFileRequester("", "", "", 0)
Debug path
Do you want to start a folder name with a blank character?

P.S.
If you have changed the IDE, the history will also work.

Re: PureBasic quit unexpectedly

Posted: Sun Jan 02, 2022 2:06 am
by Distorted Pixel
mk-soft wrote: Sat Jan 01, 2022 12:24 pm Check your path with

Code: Select all

path.s = OpenFileRequester("", "", "", 0)
Debug path
I will give the requester code a try

Do you want to start a folder name with a blank character?
If you are referring to the double quotes I have in my procedure, that is where the window title goes and I didn't want a title.
I actually want everything to be full screen at some point and not have any window borders

Re: PureBasic quit unexpectedly

Posted: Sun Jan 02, 2022 3:05 am
by Distorted Pixel
I have figured out my issue why it was saying the image didn't exist. I had a space between "/" and the next word in the directory path and obviously there can't be a space.

Now on to getting the images to show up. Images aren't showing up LOL and I'm working on getting the mouse click to be detected. I'm finding out that a lot of commands depend on others to be before them just to get the mouse detection to work ugh LOL

Re: PureBasic quit unexpectedly

Posted: Sun Jan 02, 2022 4:27 am
by Distorted Pixel
Things are starting to fall into place. I'm slowly figuring things out. I have one image showing now and I'm working on the one before it which is the splash screen.

Re: PureBasic quit unexpectedly

Posted: Sun Jan 02, 2022 1:33 pm
by mk-soft
As you can see, in macOS an application is a folder with a fixed structure. (MyApp.app)
This means that additional files belong in this folder.
These must be copied in after compiling and before starting.
To do this, I wrote an IDE tool, which I then added twice in the PB IDE in tools.

IDE-Tool MyAppdata

As with Windows and Linux, user settings are not stored in the program folder. They belong in fixed folders.

Code: Select all

;-TOP

; Comment: Path Helper v1.03 by mk-soft

; Change names
#CompanyName = "mk-soft"
#ApplicationName = "MyApplication"

CompilerIf #PB_Compiler_OS
  
  Macro CocoaString(NSString)
    PeekS(NSString, -1, #PB_UTF8)
  EndMacro
  
CompilerEndIf

Procedure.s GetProgramPath()
  CompilerIf #PB_Compiler_OS = #PB_OS_MacOS
    Static bundlePath.s
    Protected bundlePathPtr
    
    If Not Bool(bundlePath)
      bundlePathPtr = CocoaMessage(0,CocoaMessage(0,CocoaMessage(0,0,"NSBundle mainBundle"),"bundlePath"),"UTF8String")
      If bundlePathPtr
        bundlePath = CocoaString(bundlePathPtr) + "/"
      EndIf
    EndIf
    ProcedureReturn bundlePath
  CompilerElse
    ProcedureReturn GetPathPart(ProgramFilename())  
  CompilerEndIf
EndProcedure

; ----

Procedure.s GetResourcePath()
  CompilerIf #PB_Compiler_OS = #PB_OS_MacOS
    Static resourcePath.s
    Protected resourcePathPtr
    
    If Not Bool(resourcePath)
      resourcePathPtr = CocoaMessage(0,CocoaMessage(0,CocoaMessage(0,0,"NSBundle mainBundle"),"resourcePath"),"UTF8String")
      If resourcePathPtr
        resourcePath = CocoaString(resourcePathPtr) + "/"
      EndIf
    EndIf
    ProcedureReturn resourcePath
  CompilerElse
    ProcedureReturn GetProgramPath() + "Resources" + #PS$
  CompilerEndIf
EndProcedure

; ----

Procedure.s GetLibraryPath()
  Protected librayPath.s
  CompilerIf #PB_Compiler_OS = #PB_OS_MacOS
    librayPath = GetProgramPath() + "Contents/Library/"
  CompilerElse
    librayPath = GetProgramPath() + "Library" + #PS$
  CompilerEndIf
  ProcedureReturn librayPath
EndProcedure

; ----

Procedure.s GetProgramDataPath()
  Protected basePath.s, subPath.s, dataPath.s
  
  CompilerIf #PB_Compiler_OS = #PB_OS_Linux
    basePath = GetHomeDirectory()
    subPath = basePath + "." + #CompanyName + #PS$
  CompilerElse
    basePath = GetUserDirectory(#PB_Directory_ProgramData)
    subPath = basePath + #CompanyName + #PS$
  CompilerEndIf
  dataPath = subPath + #ApplicationName + #PS$
  If FileSize(dataPath) <> -2
    If FileSize(subPath) <> -2
      CreateDirectory(subPath)
    EndIf
    If FileSize(dataPath) <> -2
      CreateDirectory(dataPath)
    EndIf
  EndIf
  ProcedureReturn dataPath
EndProcedure

; ----

Procedure.s GetAllUserDataPath()
  Protected basePath.s, subPath.s, dataPath.s
  
  basePath = GetUserDirectory(#PB_Directory_AllUserData)
  subPath = basePath + #CompanyName + #PS$
  dataPath = subPath + #ApplicationName + #PS$
  If FileSize(dataPath) <> -2
    If FileSize(subPath) <> -2
      CreateDirectory(subPath)
    EndIf
    If FileSize(dataPath) <> -2
      CreateDirectory(dataPath)
    EndIf
  EndIf
  ProcedureReturn dataPath
EndProcedure

; ****

CompilerIf #PB_Compiler_IsMainFile
  Debug "Program Path: " + GetProgramPath()
  Debug "Program Resources Path: " + GetResourcePath()
  Debug "Program Libraries Path: " + GetLibraryPath()
  Debug "Program Data Path: " + GetProgramDataPath()
  Debug "Program Alluser Data Path: " + GetAllUserDataPath()
CompilerEndIf

Re: PureBasic quit unexpectedly

Posted: Sat Jan 22, 2022 5:26 pm
by Distorted Pixel
mk-soft wrote: Sun Jan 02, 2022 1:33 pm As you can see, in macOS an application is a folder with a fixed structure. (MyApp.app)
This means that additional files belong in this folder.
These must be copied in after compiling and before starting.
To do this, I wrote an IDE tool, which I then added twice in the PB IDE in tools.

IDE-Tool MyAppdata

As with Windows and Linux, user settings are not stored in the program folder. They belong in fixed folders.

Code: Select all

;-TOP

; Comment: Path Helper v1.03 by mk-soft

; Change names
#CompanyName = "mk-soft"
#ApplicationName = "MyApplication"

CompilerIf #PB_Compiler_OS
  
  Macro CocoaString(NSString)
    PeekS(NSString, -1, #PB_UTF8)
  EndMacro
  
CompilerEndIf

Procedure.s GetProgramPath()
  CompilerIf #PB_Compiler_OS = #PB_OS_MacOS
    Static bundlePath.s
    Protected bundlePathPtr
    
    If Not Bool(bundlePath)
      bundlePathPtr = CocoaMessage(0,CocoaMessage(0,CocoaMessage(0,0,"NSBundle mainBundle"),"bundlePath"),"UTF8String")
      If bundlePathPtr
        bundlePath = CocoaString(bundlePathPtr) + "/"
      EndIf
    EndIf
    ProcedureReturn bundlePath
  CompilerElse
    ProcedureReturn GetPathPart(ProgramFilename())  
  CompilerEndIf
EndProcedure

; ----

Procedure.s GetResourcePath()
  CompilerIf #PB_Compiler_OS = #PB_OS_MacOS
    Static resourcePath.s
    Protected resourcePathPtr
    
    If Not Bool(resourcePath)
      resourcePathPtr = CocoaMessage(0,CocoaMessage(0,CocoaMessage(0,0,"NSBundle mainBundle"),"resourcePath"),"UTF8String")
      If resourcePathPtr
        resourcePath = CocoaString(resourcePathPtr) + "/"
      EndIf
    EndIf
    ProcedureReturn resourcePath
  CompilerElse
    ProcedureReturn GetProgramPath() + "Resources" + #PS$
  CompilerEndIf
EndProcedure

; ----

Procedure.s GetLibraryPath()
  Protected librayPath.s
  CompilerIf #PB_Compiler_OS = #PB_OS_MacOS
    librayPath = GetProgramPath() + "Contents/Library/"
  CompilerElse
    librayPath = GetProgramPath() + "Library" + #PS$
  CompilerEndIf
  ProcedureReturn librayPath
EndProcedure

; ----

Procedure.s GetProgramDataPath()
  Protected basePath.s, subPath.s, dataPath.s
  
  CompilerIf #PB_Compiler_OS = #PB_OS_Linux
    basePath = GetHomeDirectory()
    subPath = basePath + "." + #CompanyName + #PS$
  CompilerElse
    basePath = GetUserDirectory(#PB_Directory_ProgramData)
    subPath = basePath + #CompanyName + #PS$
  CompilerEndIf
  dataPath = subPath + #ApplicationName + #PS$
  If FileSize(dataPath) <> -2
    If FileSize(subPath) <> -2
      CreateDirectory(subPath)
    EndIf
    If FileSize(dataPath) <> -2
      CreateDirectory(dataPath)
    EndIf
  EndIf
  ProcedureReturn dataPath
EndProcedure

; ----

Procedure.s GetAllUserDataPath()
  Protected basePath.s, subPath.s, dataPath.s
  
  basePath = GetUserDirectory(#PB_Directory_AllUserData)
  subPath = basePath + #CompanyName + #PS$
  dataPath = subPath + #ApplicationName + #PS$
  If FileSize(dataPath) <> -2
    If FileSize(subPath) <> -2
      CreateDirectory(subPath)
    EndIf
    If FileSize(dataPath) <> -2
      CreateDirectory(dataPath)
    EndIf
  EndIf
  ProcedureReturn dataPath
EndProcedure

; ****

CompilerIf #PB_Compiler_IsMainFile
  Debug "Program Path: " + GetProgramPath()
  Debug "Program Resources Path: " + GetResourcePath()
  Debug "Program Libraries Path: " + GetLibraryPath()
  Debug "Program Data Path: " + GetProgramDataPath()
  Debug "Program Alluser Data Path: " + GetAllUserDataPath()
CompilerEndIf
I always thought that the ".app" was the execution file extension like in Windows ".exe". I didn't know it was a a folder with a fixed structure.