• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Need your thoughts
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Need your thoughts


  • Subject: Re: Need your thoughts
  • From: Christopher Stone <email@hidden>
  • Date: Wed, 23 Feb 2011 02:56:45 -0600

On Feb 22, 2011, at 22:28, louie wrote:
Can I write a script that will have a dialog where I can type in the name and the phone number then press the ok button. After pressing the OK button I want the script to produce a application that is the name of the person. What I want to is automate the manual way I handle the script now.
______________________________________________________________________

Hey Louie,

What I prefer to do with this sort of thing is keep a table in a text file and edit the file via BBEdit (TextWrangler is BBEdit's freeware sibling).

I use the Satimage.osax's 'find text' command with regular expressions to do my lookups, but you can use tools native to Mac OS X.

set lookupTable to "
-------------------------------------------------------------
Christopher Stone,                         ;(123) 456-78910
James Dean,                                ;(098) 765-4321
-------------------------------------------------------------
"

set lookupTable to quoted form of lookupTable
set tableQuery to do shell script "egrep -io \"^[^-,]+\" <<< " & lookupTable
set AppleScript's text item delimiters to "|"
set tableQuery to text items of tableQuery
set AppleScript's text item delimiters to ""
set tableQuery to tableQuery as text
set AppleScript's text item delimiters to return
set tableQuery to text items of tableQuery
set tableQuery to choose from list tableQuery
if tableQuery ≠ false then
   set tableQuery to tableQuery as text
   set dialNumber to do shell script "egrep " & quoted form of tableQuery & " <<< " & lookupTable
   set AppleScript's text item delimiters to ";"
   set dialNumber to last text item of dialNumber
end if

This is very quick and dirty and is much easier using the Satimage.osax (or shelling out to Perl, Ruby, or Python).  Nevertheless you can do it with pure Applescript.

I don't like to use script applications; I much prefer to use FastScripts, or QuicKeys, or Keyboard Maestro. (FastScripts being my script-runner of choice.)

I usually assign my lookup table a global or app-specific keyboard shortcut, so I can open and edit it with ease.

In the case of a script similar to the above I'll 'read' the text file rather than embed it in the script (unless the lookup table is very static).

--
Best Regards,
Chris
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users

This email sent to email@hidden

  • Follow-Ups:
    • Re: Need your thoughts
      • From: Christopher Stone <email@hidden>
References: 
 >Need your thoughts (From: louie <email@hidden>)

  • Prev by Date: Re: Need your thoughts
  • Next by Date: Re: Need your thoughts
  • Previous by thread: Re: Need your thoughts
  • Next by thread: Re: Need your thoughts
  • Index(es):
    • Date
    • Thread