Refrencing Copy Files OSX

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
doobox
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 284
Joined: Tue May 24, 2011 11:47 pm

Refrencing Copy Files OSX

Post by doobox » Wed Mar 14, 2012 10:20 am

Hi there,

I am stuck on something that seems should be so simple..

How do i reference the path to a file or folder placed in my application via the copy files window in application settings.

I am used to using specialFolderPath(engine) on ios, but this does not seem to work in a desktop app.

So my file in copy files for example shows .. Keys/myfile.txt
how do i get that into a variable.?

Code: Select all

put ???????????? into tMyFileFromApplication
Also is there a universal path so it will work in both edit and stand alone..?
Kind Regards
Gary

https://www.doobox.co.uk

Klaus
Posts: 14196
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Refrencing Copy Files OSX

Post by Klaus » Wed Mar 14, 2012 12:13 pm

Hi Gary,

specialfolderpath("engine") unfortuntately only works on MOBILE, but it would make a lot of sense for the desktop, too!

I always use a little function that returns the "ENGINE" folder for me, will work for Mac and Windows:

Code: Select all

function tAppPath
  put the filename of stack "your standalone mainstack here" into tPath
  set itemdel to "/"

  ## We only need the folder NOT the filename of the runtime!
  delete item -1 ot tPath
  return tPath
end tAppPath
Then use it like this:

Code: Select all

...
put tAppPath() & "/Keys/myfile.txt" into tMyFileFromApplication
...
Best

Klaus

doobox
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 284
Joined: Tue May 24, 2011 11:47 pm

Re: Refrencing Copy Files OSX

Post by doobox » Wed Mar 14, 2012 12:34 pm

Many Thank's,

Works a treat..
So Looks like we cant work with relative paths then (surprised)..?

I was surprised i could not just do this with a file in my copy files that resides in the same folder as the stack on my system:

Code: Select all

play "ding.wav"
As the standalone will also contain the file in the same folder as the built app.
Kind Regards
Gary

https://www.doobox.co.uk

Klaus
Posts: 14196
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Refrencing Copy Files OSX

Post by Klaus » Wed Mar 14, 2012 12:40 pm

Hi Gary,

the filepath hierarchie and "the defaultfolder" are different in a standalone than in the IDE.
When you start a runtime "the defaultfolder" will be the folder where the APP or EXE resides.

So you need to use little tricks like my function :-)
...
play (tAppPath() & "/ding.wav")
## or
play (tAppPath() & "/sounds/ding.wav")
...


Best

Klaus

Post Reply