Hey all,
I am trying to write a program which upload certain files to a server. I would also like to have the program remember the server info upon each launch so that the user doesn’t have to type it in each type they run the program
I have found a way to retrieve values from an external applescrit file and load them into text fields in my AppleScript Studio App. That was pretty easy.
Here is the code that I have for that . . .
if the name of theObject is "showServerInfo" then
set myScriptPath to "/testVariables.scpt"
set myScriptPath to POSIX file myScriptPath
set serverInfo to load script file myScriptPath
tell serverInfo
set contents of text field "userName" of window "mainWindow" to its userID as string
set contents of text field "passPhrase" of window "mainWindow" to its passPhrase as string
set contents of text field "serverURL" of window "mainWindow" to its serverURL as string
set contents of text field "serverPath" of window "mainWindow" to its folderPath as string
end tell
The “testVariables.scpt” file looks like . . .
property userID: "xxx" --where xxx is a real value
property passPhrase: "yyy"
property serverURL: "zzz"
property folderPath: "ranOutOfLetters"
Ideally, once these values are present in the external file, they will load automatically at the startup. This should be a problem for me (I do realize that the above code is dependent on a button click).
But this is only helpful if the external file already has the values. I need a way to write what a user would type into the text fields to the external file, and can’t figure it out.
Here is what I have, but I can’t for the life of me figure out how this might work.
else if the name of the theObject is "saveServerInfo" then
set myScriptPath to "/testVariables.scpt"
set myScriptPath to POSIX file myScriptPath
set serverInfo to load script file myScriptPath
tell serverInfo
set its userID to the contents of text field "userName" of window "mainWindow"
set its passPhrase to the contents of text field "passPhrase" of window "mainWindow"
set its serverURL to the contents of text field "serverURL" of window "mainWindow"
set its folderPath to the contents of text field "serverPath" of window "mainWindow"
end tell
end if
How might I get this to work so that the newly typed in values will get saved into the external applescript file? If this is not possible (It seems that it should be), how might I go about doing this?