Username and password applescript

Here is the script I have to create a user name and password. It saves it in a folder as a text document that displays the username and password.

set fullname to text returned of (display dialog "ENTER YOUR FIRST AND LAST NAME" default answer "")
set username to text returned of (display dialog "ENTER YOUR DESIRED USERNAME" default answer "")
set pass to text returned of (display dialog "ENTER YOUR PASSWORD" default answer "")
set passverified to text returned of (display dialog "PLEASE VERIFY YOUR PASSWORD" default answer "")
if passverified is "" & pass & "" then
	tell application "TextEdit"
		activate
		set myDoc to make new document at end
	end tell
	tell application "System Events"
		keystroke "" & username & ""
		key code 36
		keystroke "" & pass & ""
	end tell
	tell myDoc
		save myDoc in "Users:garrett:Documents:passwords:" & fullname & ""
		quit
	end tell
else
	display dialog "Passwords do not match"
end if

Now, I want to create an applescript where you have to enter your username and password and it searches the folder for the text document that has the username and password in it. If it finds one, I’ll go from there. If, it doesn’t it will

display dialog "Please try again"

So can anyone give me a script to do that? Or maybe give me an easier way to do this.

Hi,

I don’t understand the benefit to read a text file which contains only the information you’ve just entered,
but AppleScript can create text files without using TextEdit


set targetFile to ((path to documents as text) & "passwords:" & fullname & ".txt")
try
	set ff to open for access file targetFile with write permission
	write username & return & pass to ff
	close access ff
on error
	try
		close file targetFile
	end try
end try

Ok, I’m not very smart with applescripting at all. What exactly is the code you gave me doing? And how come I get an error when trying to run it.

sorry, I forgot the keyword folder


.
set targetFile to ((path to documents folder as text) & "passwords:" & fullname & ".txt")
.

the script above replaces the TextEdit part of your script, it’s writes username & return & pass to disk

Ok I get it now. But so now how do I do this?

Kind of like any time you would enter a user name and password. I want two dialog boxes where you type the user name and password.