Why do i have to use an absolute path to load a resource?

Mac OSX specific forum
User avatar
LESTROSO
Enthusiast
Enthusiast
Posts: 124
Joined: Thu Nov 03, 2005 12:30 pm
Location: Italy
Contact:

Why do i have to use an absolute path to load a resource?

Post by LESTROSO »

:o Hy,
Why do i have to use an absolute path to load a resource?
In the window version you can load an image or sound like this:

;
; ------------------------------------------------------------
;
; PureBasic - Keyboard example file
;
; (c) 2001 - Fantaisie Software
;
; ------------------------------------------------------------
;
; NOTE: This file doesn't compile with the demo version !
;

If InitKeyboard() = 0
MessageRequester("Error", "Can't open DirectX 7", 0)
End
EndIf

If InitSprite() = 0
MessageRequester("Error", "Can't open DirectX 7", 0)
End
EndIf

MessageRequester("Information", "This will test the fast keyboard access..."+Chr(10)+"Press 'ESC' to quit!", 0)

If OpenScreen(640, 480, 16, "Sprite")

x = 100
y = 100

Code: Select all

  If LoadSprite(0, "data/Player_1.bmp", 0) = 0
CloseScreen()
MessageRequester("PureBasic", "Can't load the sprite file (data/Player_1.bmp)", 0)
End
EndIf

Repeat

FlipBuffers()
ClearScreen(0,0,0)

ExamineKeyboard()

If KeyboardPushed(#PB_Key_Left)
x-1
EndIf

If KeyboardPushed(#PB_Key_Right)
x+1
EndIf

If KeyboardPushed(#PB_Key_Up)
y-1
EndIf

If KeyboardPushed(#PB_Key_Down)
y+1
EndIf

DisplaySprite(0, x, y)

Delay+1
Until KeyboardPushed(#PB_Key_Escape) Or Delay > 5000

Else
MessageRequester("Error", "Impossible to open a 680*480 16 bit screen",0)
EndIf

End
--------------------------------------------------------------------------------
This is a PureBasic example, but if you try, this don't work, because the compiler can't find the path, like the Keyboard example like this.

Could anyone tell me if you have the same problem??? :cry: :cry: :cry:
SEO
Enthusiast
Enthusiast
Posts: 178
Joined: Fri Dec 09, 2005 11:42 pm
Location: Sweden
Contact:

Post by SEO »

Yes, we all have the same 'problem' ... This because an Mac OS X application (when you compiled your app) is an 'bundle' ... That contains your executable and some folders.

So your 'paths' would not be the same in an Mac OS X bundle as the PB IDE. (it is the same in other developing tools for Mac)

But this is not an 'problem', it is simple to solve.
I have built an demo application that you only change one line of code to solve the 'problem'

There is an example here that show how to handle this and also using dylibs ...
http://www.xhtmlsoft.com/pb/macskeleton.html
User avatar
LESTROSO
Enthusiast
Enthusiast
Posts: 124
Joined: Thu Nov 03, 2005 12:30 pm
Location: Italy
Contact:

Post by LESTROSO »

:o thank seo..........but when i have tryed the 3.94 mac version this worked.........bhoo??!!!....but i think you're right......

thanks for your opinion..... :wink:
SEO
Enthusiast
Enthusiast
Posts: 178
Joined: Fri Dec 09, 2005 11:42 pm
Location: Sweden
Contact:

Post by SEO »

Yes i think that is correct, but then it not worked in an bundle...
User avatar
LESTROSO
Enthusiast
Enthusiast
Posts: 124
Joined: Thu Nov 03, 2005 12:30 pm
Location: Italy
Contact:

Post by LESTROSO »

:lol: thanks seo......
Post Reply