Problem with open file command

Ken Ray kray at sonsothunder.com
Sun Jan 16 00:34:02 EST 2005


On 1/15/05 11:28 PM, "Stgoldberg at aol.com" <Stgoldberg at aol.com> wrote:

> I have been trying to get the "open file" command to work on my G5 mac, e.g.
> trying to open a ".txt" file in the same folder as the application, but
> nothing happens.   Can anyone suggest what I might be doing wrong, and also
> what 
> sort of "files" one should expect Revolution to be able to open with this
> command?   Thanks.

Well, the "open file" command just opens a file so that you can take some
action on it (read from it, write to it, etc.). If your intent is to read
all the data from a file and put it into a variable, there are two ways -
the long way:

  open file <pathToFile>
  read from file <pathToFile> until eof
  close file <pathToFile>
  put it into MyVar

and the short way:

  put url("file:"<pathToFile>) into MyVar

The <pathToFile> is substituted with either a full path or a relative path
from where the 'defaultFolder' is pointing (which by default for standalones
is the folder where the standalone resides). So let's say I had a file
called "Prefs.txt" that was in the same folder as my standalone. I could to
this:

  put url("file:Prefs.txt") into MyVar

If it was in a folder called "Support", I could call it like this:

  put url("file:Support/Prefs.txt") into MyVar

You get the idea...

Ken Ray
Sons of Thunder Software
Web site: http://www.sonsothunder.com/
Email: kray at sonsothunder.com




More information about the use-livecode mailing list