Checking a text field, and a few other problems

Hey guys,

I know its been said, but a big thanks for just having this forum, its helped me starting out with applescript more then any book. I do have a few questions I couldnt find by searching, and am not sure this is the right place to post them, but here goes…

  1. In my app, I have a username and password box and I would like for my app to check if they entered a username before continuing on (Hope that made sense :-p). Heres the code I have now…

though each time that part of the app runs, it just displays the dialog, no madder whats in the text box.

edit: I think the problem may be with my use of how I get the info from the text fields, right now I am using…

  1. In the same app, when the dialog pop’s up, it erases whats entered into the text field, is there any way I can stop it from doing that?

  2. Also, I would like to be able to save the password and username that was entered for next use (or at least the username), is there a safe way for me to do this? Dont want to have the password just sitting in a text file somewhere or in the app :smiley:

Any help on these would be appreciated, thanks!!

Not sure. I don’t do much studio stuff.

When you say…

set contents of the text field “username” to user
set contents of the text field “password” to pass

do you mean…

set theUserVar to contents of the text field “username”
set thePassVar to contents of the text field “password”


You say this bit of code is what you use to get info from the text fields. What you’re doing looks like you’re setting info to the text fields. I’m not sure I understand your intention here.

Not sure what the solution to #2 would be. if you set a field value before displaying the dialog, the dialog init will re-initialize the values. Is there an onLoad event you can put this code into? Someone with AS Studio chops could tell you.

Question #3: If a user authenticates properly, you could save the user-name/pass in a text file on their HD. You could use a bit of do shell script to encrypt/decrypt the password. (In terminal, man crypt or man passwd.) This is semi-safe. Once your app is compiled, it would be hard to find your crypt hash. There are lots of approaches to this. How you do it depends on how secure you need to be. I don’t know what you’re authenticating against or if you need to send passwords over the network as plaintext.


Thanks, yea, you can safely ignore quesiton 1, got that bit worked out (I am new to applescript :slight_smile: ).

as for 2, maybe have it save whats been typed to a file right after they finish typing it? using the “end editing”? Its a user/password box as you can tell, and I would like for it so that I dont have to retype it each time I were to see a dialog.

I agree about number three, I am a unix guy myself, and just was wondering if applescript had any way of doing that, I already wrote out some code for what you suggested as my fallback.