Opening a stack without a .livecode extension

Richard Gaskin ambassador at fourthworld.com
Thu Sep 29 11:06:55 EDT 2016


Graham wrote:

 > I’ve got a preferences stack which is called something like “my
 > preferences”. It’s not called “my preferences.livecode”. It’s a
 > mainstack, not a substack of any other. The path to the stack is
 > of the form
 >
 > /Users/Graham/Library/Preferences/my preferences
 >
 > If I put the path to the stack in a variable and then try to open it
 > from within another stack, as in
 >
 > go card 1 of stack pathToMyStack
 >
 > It doesn’t open and ‘exists’ says it doesn’t exist - but it can be
 > opened from the IDE.

I'm assuming by "opened from the IDE" you mean via the File -> Open 
Stack menu item, yes?

If so, then it would seem most likely the culprit is the path.

With any file I/O operations it's helpful to check both the result and 
the sysError function; the former will let you know something is wrong, 
and the latter will let the OS tell you exactly what the problem is.

Try this:

    go card 1 of stack pathToMyStack
    if the result is not empty then
       answer the result & " (&" sysError() &")" & cr \
         & pathToMyStack
       exit to top
    end if

This will tell you:
- What LiveCode thinks the problem is
- What the OS thinks the problem is
- Whether the path looks like what you think it should look like

sysError will return an integer that reflects the OS error code.  Most 
OS vendors provide lists of error codes, so if the error isn't obvious 
from the other feedback in that answer dialog a quick Google search 
should help you find exactly what you need to resolve it.


 > I thought at first this was because I didn’t include an extension
 > (“.livecode”), but that’s not apparently the issue.

Yes, LiveCode will open any file in a valid LiveCode stack file 
regardless of the file name extension.  This is by design, allowing us 
to use stack files as documents or other persistent storage in our own 
apps if we like.

-- 
  Richard Gaskin
  Fourth World Systems
  Software Design and Development for the Desktop, Mobile, and the Web
  ____________________________________________________________________
  Ambassador at FourthWorld.com                http://www.FourthWorld.com





More information about the use-livecode mailing list