Get the Directory of the Main Stack with AppPath() Function
Mac OS 9 Mac OS X Windows Linux

Some time ago I wrote here about the benefits of using a central function to determine the path to your main stack, primarily for referring to media located relative to your stack whether it’s running under MC or as a standalone.

Unfortunately, the Mach-O package structure (now used in MC 2.4.3 (and in the forthcoming Rev 2.0 - Ed)) changes the value of the filename of a stack: instead of referring to the apparent location (where the *.app bundle is located) it points to the actual executable file nested a couple folders down inside the package.

If you consistently use the AppPath function to concatenate filenames, replacing it with these will correct for this undocumented change:

function AppPath
  put the filename of this stack into tPath
  set the itemdel to "/"
  If (IsOSX()) then
    get offset(".app/Contents/MacOS/", tPath)
    if it > 0 then -- 2.4.3 or later
      delete char it to len(tPath) of tPath
    end if
  end if
  delete last item of tPath
  return tPath &"/"
end AppPath

function IsOSX
  if the platform is not "MacOS" then return false
  get the systemversion
  set the itemdel to "."
  if item 1 of it >= 10 then return true
  return false
end IsOSX
If your paths are handled by any other means you may need to duble check your code.

The initial value of the directory global property remains unchanged from previous versions, but as noted in earlier posts relying on that is less convenient during development since you’ll likely not want to keep all of your work files in the same folder as the MC application.

Richard Gaskin
Fourth World Media Corporation
Custom Software and Web Development for All Major Platforms
Developer of WebMerge 2.0: Publish any Database on Any Site
___________________________________________________________
Ambassador@FourthWorld.com      http://www.FourthWorld.com
Tel: 323-225-3717                           AIM: FourthWorldInc

Posted 9/21/2002 to the MetaCard List   (See the complete post/thread)