Page 1 of 1

Refrencing Copy Files OSX

Posted: Wed Mar 14, 2012 10:20 am
by doobox
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..?

Re: Refrencing Copy Files OSX

Posted: Wed Mar 14, 2012 12:13 pm
by Klaus
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

Re: Refrencing Copy Files OSX

Posted: Wed Mar 14, 2012 12:34 pm
by doobox
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.

Re: Refrencing Copy Files OSX

Posted: Wed Mar 14, 2012 12:40 pm
by Klaus
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