Page 1 of 1

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

Posted: Wed Mar 29, 2006 11:18 am
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:

Posted: Fri Mar 31, 2006 8:13 pm
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

Posted: Fri Mar 31, 2006 8:49 pm
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:

Posted: Fri Mar 31, 2006 8:54 pm
by SEO
Yes i think that is correct, but then it not worked in an bundle...

Posted: Sat Apr 01, 2006 12:11 pm
by LESTROSO
:lol: thanks seo......