Files

Ken Ray kray at sonsothunder.com
Sun Jan 2 13:33:21 EST 2005


On 1/2/05 11:49 AM, "Robert Sabo" <viper4559 at yahoo.com> wrote:

> Ok quick question. Lets say I am going to make a
> program that you add accounts to. And for these
> accounts the program must know a username and
> password. Well, I need for the program to remember the
> username and password after I exit the program. So how
> would I have it save these to a file and then open
> them back up and remember them correctly?

Well, if you have a standalone and don't change the default directory, the
"defaultFolder" is pointing to the same folder as the standalone. So if you
do this:

  put "Ken Ray,password" into url("file:prefs.txt")

it will insert the string "Ken Ray,password" into a file called "prefs.txt"
in the same directory as the standalone. To retrieve it, do:

  put url("file:prefs.txt") into tLoginInfo
  put item 1 of tLoginInfo into tName
  put item 2 of tLoginInfo into tPassword

However even though the above works, it is not very secure; if someone opens
the file, they'll see everything plain as day. So I'd suggest using either
the urlEncode() or base64Encode() functions (or both) to make it harder to
read, as in:

  put base64Encode("Ken Ray,password") into url("file:prefs.txt")

and then when you retrieve it, do:

  put base64Decode(url("file:prefs.txt")) into tLoginInfo

You should also probably write the file to some other folder other than the
standalone's so it is not immediately apparent to people where the user
names and passwords are stored. Check the "specialFolderPath" entry in the
Transcript Dictionary for details.

> Also, how would I create a standalone program?

To create a standalone program, just look under the File menu for menu items
called "Standalone Application Settings..." and "Save As Standalone
Application".

HTH,

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