Mac Help Forums


Reply
Thread Tools Display Modes

applescript to verify password from list

 
New Member
Join Date: Sep 2011
Posts: 2
 
      8th September 2011
Simple question: The script (in blue below) requires user to enter password to continue. I would like it to allow a correct match from a list. So instead of the line that reads:

if pass is "2432" then
I would like something like:
if pass is "2432" or "2355" or "1243" then
or even better would be a list: "2432" , "2355", "1243"

Any help would be appreciated.

==== ORIGINAL SCRIPT ==========
set pass to text returned of (display dialog "PLEASE ENTER YOUR REGISTRATION NUMBER" default answer "")
if pass is "2432" then
tell application "TextEdit"
activate
set myDoc to make new document at end
end tell


else
display dialog "Passwords do not match"
end if
 
Reply With Quote
 
 
 
 
Senior Member
Kaveman's Avatar
Join Date: Nov 2010
Location: Westland, NZ
Posts: 1,355
 
      9th September 2011
Code:
set pass to text returned of (display dialog "PLEASE ENTER YOUR REGISTRATION NUMBER" default answer "")

set holdAnswers to {"2432", "2355", "1243"}
if pass is in holdAnswers then
	tell application "TextEdit"
		activate
		set myDoc to make new document at end
	end tell
	
	
else
	display dialog "Passwords do not match"
end if
 
Reply With Quote
 
New Member
Join Date: Sep 2011
Posts: 2
 
      13th September 2011
Thanks Kaveman - it worked great.

Another question. I want to add to add to that applescript so it would:

a - copy files using a relative path.
b - open a package relative to the script location (all files are in the same folder). I can open it if I use an absolute path, but I need it to be relative as the user may run it from anywhere (download, CD, etc..).

The red is what I cannot get to work.

set pass to text returned of (display dialog "PLEASE ENTER YOUR REGISTRATION NUMBER" default answer "" buttons {"OK"})

set holdAnswers to {"2432", "2a.3", "1243"}
if pass is in holdAnswers then


tell application "Finder" to duplicate file "1345.EE" to folder "Applications" of startup disk with replacing

tell application "Finder"
activate
open document file "Install.pkg"
end tell


else
display dialog "You did not enter a valid registration number. Please re-install the program and carefully enter your registration number."

end if

Last edited by jayer; 14th September 2011 at 12:02 AM..
 
Reply With Quote
 
Senior Member
Kaveman's Avatar
Join Date: Nov 2010
Location: Westland, NZ
Posts: 1,355
 
      13th September 2011
Code:
--Note this only works if the target Folder:File is in that same Folder as the script

set holdScriptNameLength to 9 -- this is the length of your scriptname including .scpt
set myPath to (path to me) as string
set myLength to the number of characters of myPath
set myPath to (characters 1 thru (myLength - holdScriptNameLength) of myPath) as string
set myPath to myPath & "Inside:song.rtf" -- folder : folder : fileName.extention

tell application "Finder"
	open myPath
	
end tell
Any Path manipulation in AppleScript is not nice, thats why people use things like Perl for jobs like this.
 
Reply With Quote
 
 
 
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Heirarchical List w/Password Protection? (PeteCresswell) iPod 1 9th May 2010 08:01 PM
AppleScript for password on external HD? vagabond AppleScript 0 19th April 2010 10:35 AM
applescript remove duplicate list items Phantom AppleScript 4 1st May 2008 04:43 AM
Property List and AppleScript sdebrois@gmail.com Programmer Help 1 24th May 2007 09:44 AM
How to verify the DNS IP ? C-A Berseth Mac 7 24th October 2004 01:56 PM


All times are GMT +1. The time now is 01:34 PM.
Mac-Help.com is an independent website and is not affiliated with Apple Inc.


Welcome!
Welcome to the Mac Help Forums
 


Latest Threads
PDF Document
yura (1 Hour Ago, 12:13 PM)

Difficulties with internet speed (nothing to do with connection)
sammethh (6 Hours Ago, 06:36 AM)

Deleting a homepage/website form my mac book pro
rgandajg (15 Hours Ago, 10:30 PM)

MacBook
basil422 (19 Hours Ago, 06:01 PM)

Outlook reminders not popping up
WonderBot (20 Hours Ago, 05:03 PM)

 


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51