applescript to verify password from list

Discussion in 'AppleScript' started by jayer, Sep 8, 2011.

  1. jayer

    jayer New Member

    Joined:
    Sep 8, 2011
    Messages:
    2
    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
     
    jayer, Sep 8, 2011
    #1
    1. Advertisements

  2. jayer

    Kaveman VIP Member

    Joined:
    Nov 26, 2010
    Messages:
    3,559
    Location:
    Westland, NZ
    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
     
    Kaveman, Sep 9, 2011
    #2
    1. Advertisements

  3. jayer

    jayer New Member

    Joined:
    Sep 8, 2011
    Messages:
    2
    Relative paths for opening packages

    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
     
    jayer, Sep 13, 2011
    #3
  4. jayer

    Kaveman VIP Member

    Joined:
    Nov 26, 2010
    Messages:
    3,559
    Location:
    Westland, NZ
    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.;)
     
    Kaveman, Sep 13, 2011
    #4
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Newsbot
    Replies:
    0
    Views:
    690
    Newsbot
    May 26, 2007
  2. BioCore
    Replies:
    0
    Views:
    562
    BioCore
    Sep 13, 2007
  3. Newsbot
    Replies:
    0
    Views:
    579
    Newsbot
    Sep 20, 2007
  4. Newsbot

    Mac OS X: How to Verify a SHA-1 Digest

    Newsbot, May 22, 2008, in forum: Apple News
    Replies:
    0
    Views:
    429
    Newsbot
    May 22, 2008
  5. Kurt R. Todoroff
    Replies:
    1
    Views:
    408
    David Empson
    Sep 16, 2009
  6. Koncept

    copy class of list values to a new list

    Koncept, Feb 11, 2004, in forum: AppleScript
    Replies:
    3
    Views:
    510
    Michelle Steiner
    Feb 12, 2004
  7. (PeteCresswell)

    Heirarchical List w/Password Protection?

    (PeteCresswell), May 9, 2010, in forum: iPod
    Replies:
    1
    Views:
    273
    nospam
    May 9, 2010
  8. wildpix
    Replies:
    1
    Views:
    472
    Kaveman
    Aug 16, 2013
Loading...