Script writing to itself or changing itself

Okay you guys are awesome everytime when I come here for scripting help, so maybe you can help me with this one as well.
I want to add two little lines to an Apple script and then be able to run it right away without having to save it as an App. That’s confusing I know, but here is what I want to do:
I have a backup script for our users. It works great. Connects to the server, copies the data, renames the data to todays date. It’s all good.
The problem is everyone has a different user name, and there are three different servers. The user’s name is their folder name as well. I could write a custom script for every single person. That would be keen and all but there are 400+ people and it would be easier, and the script would last longer if there was a way for them to enter their user name and server name themselves. The catch is I want them to only have to do it once. Basically I want either a script that is a setup script that runs asks for the info, puts it in the backup script, and then they can run the modified backup script. Again, because of the way our systems are loaded it is not trivial to have scripts use any additions other than what comes with OS 9 applescript.
My hopes is the users will be able to download this from a website, run the setup, and never have to worry about it again, as do the support staff.

: Okay you guys are awesome everytime when I come here for
: scripting help, so maybe you can help me with this one as
: well.
: I want to add two little lines to an Apple script and then be
: able to run it right away without having to save it as an App.
: That’s confusing I know, but here is what I want to do: I have
: a backup script for our users. It works great. Connects to the
: server, copies the data, renames the data to todays date. It’s
: all good.
: The problem is everyone has a different user name, and there are
: three different servers. The user’s name is their folder name
: as well. I could write a custom script for every single
: person. That would be keen and all but there are 400+ people
: and it would be easier, and the script would last longer if
: there was a way for them to enter their user name and server
: name themselves. The catch is I want them to only have to do
: it once. Basically I want either a script that is a setup
: script that runs asks for the info, puts it in the backup
: script, and then they can run the modified backup script.
: Again, because of the way our systems are loaded it is not
: trivial to have scripts use any additions other than what
: comes with OS 9 applescript.
: My hopes is the users will be able to download this from a
: website, run the setup, and never have to worry about it
: again, as do the support staff.
The easiest way to accomplish this is with properties. If your
backup script is saved and used as an application, anything
which is stored in the properties will be retained, unless the
script is recompiled. For instance:
– Begin Sample Code –
property userName : “”
if userName is “” then
display dialog “Please enter your username.” default answer “”
set userName to text returned of result
end if
– End Sample Code –
The username, once entered, will be retained until the script is
opened in a script editor and recompiled.
Depending on your needs, you may need to add some
additional code to trap for all of the various things that users
might do which will break the script. For instance, you might
want to display another dialog which allows the user to confirm
that they have entered the correct username.
Later,
Rob J

: The easiest way to accomplish this is with properties. If your
: backup script is saved and used as an application, anything
: which is stored in the properties will be retained, unless the
: script is recompiled. For instance: – Begin Sample Code –

: property userName : “”

: if userName is “” then display dialog “Please
: enter your username.” default answer “” set
: userName to text returned of result end if

: – End Sample Code –

: The username, once entered, will be retained until the script is
: opened in a script editor and recompiled.

: Depending on your needs, you may need to add some additional
: code to trap for all of the various things that users might
: do which will break the script. For instance, you might want
: to display another dialog which allows the user to confirm
: that they have entered the correct username.

To avoid the problem of forcing everyone to reenter their info when you need to recompile the script you might add another feature: writing out the script property to a text file when it changes and reading it into the property when the script starts up. This also gives you a backup of the users in case the script itself ever becomes corrupted. If you’ve got a list of usernames somewhere, you could initialize the text file with it and then current users wouldn’t have to enter them at all.
Marc K. Myers
Marc@AppleScriptsToGo.com
AppleScriptsToGo
4020 W.220th St.
Fairview Park, OH 44126
(440) 331-1074

[02/14/2002 12:51:38 PM]

Or, alternatively, keep an empty folder with that name property next to the script…
E. Houwink
: To avoid the problem of forcing everyone to reenter their info
: when you need to recompile the script you might add another
: feature: writing out the script property to a text file when
: it changes and reading it into the property when the script
: starts up. This also gives you a