OCInkjet.com 728x90 banner, image is updated by season.

Apple-AppleScript-Script-Editor-Logo

Shop HP Download Store and get $5 OFF Orders Over $50! Use Promo Code SPEND150SAVE15

Basic AppleScript Dialog:

display dialog "Your text here" with icon stop buttons {"OK"} default button {"OK"} giving up after 5

'giving up after 5' will automatically close the script after the indicated interval of time has elapsed.

HTML Anchor Code

Here is a sample of how to write code to link one part of your blog page to another:

<a name = "By Email">[optional text]</a> --place this where you want the link to go <a href = "#By Email">By Email</a> --this is the actual link

more HTML

HTML Code to Link to Other Web Pages

Here is a sample of code to link to another page. this is similar to the anchor code, except that the destination code is the url of the destination site:

<a href= "www.webSite.
com"> Website Name</a>

--just replace "www.webSite.
com"
with the actual url destination site and replace 'Website Name' with the prompt that the user will see.
Apple-IIc-Apple-Screen

AppleScript Note:

It might be interesting to those of you who are AppleScript enthusiasts that the HyperCard (HyperTalk) project was the prototype back in the '80's of what became the system-wide Applescript language (akin to JavaScript) that is in use today.
Apple-Mac-512-Screen
3d-iMac-Large

Trapping for List Dialog Errors

With 'List Dialog' type dialogs, since errors cannot be intercepted in an 'on error' handler, there is no 'normal' way to trap for 'Cancel' which, of course, would result in some sort of undesirable error dialog such as 'User cancelled. Error number -128'. Here is an example of one simple way I have found to trap for this type of error: set x to (choose from list {"Joe","Amy",
"Bill"} with prompt "Choose a record:")
if x is false then
else
set targetItem to (x as text)
show every record whose cell "Name" contains x
end if
When the user clicks on 'Cancel', the variable x is assigned the boolean value false. So all you have to do is set up a conditional to deal with that and to perform the usual statements otherwise.

Learning AppleScript

Create Multiple Folders with Terminal

If you are more of a techy kind of person and are comfortable with using Terminal, here is a script you can use to easily create multiple folders:

First, for a single folder, type in: mkdir "Folder 1" --or whatever you want to name your folder, this creates a new directory, which, in effect is a new folder. To place multiple items in the 'Documents' folder: cd/Users/ Administrator/ Documents mkdir "Folder 1" "Folder 2" "Folder 3" To quickly create multiple folders, create a text file with the desired folder names (as many as you want) and name it something like 'folderList .txt'. Next type this in Terminal: cat folderList.txt |xargs mkdir Or you could create folders with the same prefix by entering: mkdir "Invoices " {"Corporate", "Individual", "Pro-Bono"}

Digg! Digg This!!

Mac LC III (1994), the first Mac that I ever owned, the CD-Rom and Zip drive were added much later.

Mac LC III (1994), the first Mac that I ever owned, the CD-Rom and Zip drive were added much later.

Basic HTML

Here is an example of a very simple HTML document:

<html>
<head>
<title>Basic HTML Document</title>
</head>
<body>
Your text goes here
</body>
</html>

more HTML

More on List Dialogs

Apple Mac LCIII Shipping 300x164This post will deal with what I consider a very concrete use of the ‘choose from list’ dialog. After reading this (and perhaps trying it out in the Script Editor) you will probably be totally confused (just kidding!!) It gets a little complicated, but it is basically a cut-and-paste script.

If you pay close attention to my comments, I’m sure you’ll understand most of what is going on and, after all, it’s understanding how a script works that allows you adapt it to other applications that you may have in mind.

So anyway, here it is:

set AppleScript's text item delimiters to ","

–this first line is needed, because it sets things up for extracting the info we need

set theLongDate to (current date)
set theLongDate to (date string of theLongDate)

–the next 2 lines set us up for calculating the numerical data for month and day

set currentMonth to (word 1 of text item 2 of theLongDate)
set currentDay to (word 2 of text item 2 of theLongDate)

–this gets the numerical value for the month

set currentYear to (word 1 of text item 3 of theLongDate)
set monthList to {January, February, March, April, May, June, July, August, September, October, November, December}
repeat with x from 1 to 12
if currentMonth = ((item x of monthList) as string) then
set theRequestNumber to (text -2 thru -1 of ("0" & x))
exit repeat
end if
end repeat
set currentMonth to theRequestNumber
set currentDay to (text -2 thru -1 of ("0" & currentDay))
set theShortDate to (currentMonth & "/" & currentDay & "/" & currentYear) as string

–previous code sets up the default text (current date in the form mm/dd/yyyy – something like ’02/03/2009′) for dialog below :

set theDefaultDate to text returned of (display dialog "Enter a date in the form MM/DD/YYYY:" default answer theShortDate buttons {"Calc Date"} default button {"Calc Date"} giving up after 20)

–this line converts the text supplied by the dialog into class ‘date’ (the long form of the date, including the time):
set calcLongDate to date theDefaultDate

–this line extracts the date portion and leaves the time portion behind:
set calcLongDateTrunc to (date string of calcLongDate)

–this converts calcLongDateTrunc back into the form ‘text’ so that it can be displayed in a dialog:
set calcLongDateTrunc to calcLongDateTrunc as string
display dialog calcLongDateTrunc buttons {"Done"} default button {"Done"} giving up after 15

–yields – ‘Tuesday, February 3, 2009′

Apple Mac Interface Banner

In my next post, I will shift gears and present an AppleScript which I have derived from one of my FileMaker programs, which serves as a convenient file backup program.

In conclusion, please note in my right sidebar (you may have to scroll), that in the future I will be featuring (here and there) little snippets of HyperTalk code (and others as they occur to me)

As always, if you have any questions or comments, contact me at: hyperscripter@gmail.com or http://twitter.com/hyperscripter or to subscribe, click the By Email link at the top of the page

Technology Search


421 comments to More on List Dialogs

  • It a great idea! Just wanna say thank you for the information you could have posted. Just continue publishing this sort of post. I am about to a loyal reader, thanks a lot.

  • Just killing some in between class time on Digg and I discovered your article . Not usually what I desire to examine, but it was completely value my time. Thanks.

  • I bought some nice info here. I think that in case a greater number of people thought of it like this, they’d possess a better time get the hang ofing the matter.

  • We simply shared your website and wished to say that I have really enjoyed reading your blog posts. By any means I’ll be subscribing to your feed rss now, thanks

  • I really like what you guys tend to be up too. This sort of clever work and coverage! Keep up the superb works guys I’ve incorporated you guys to blogroll.

  • I need to exhibit my passion for one’s understanding giving assist to firmly personnel that need relief on that region of curiosity. Your personal enthusiasm to actually receiving the note all-around came into existence incredibly invaluable but has in every issue enabled women somewhat like me to arrive over at their likes and dislikes. Your unique humid and friendly guidance indicates tons with me and pretty well additional upto my consorts. Best wishes; from each one of us.

  • It a wonderful idea! Just wanna say thank you of the news you have diffused. Just continue composing one of these post. I am going to a loyal reader, thanks a lot.

  • Thanks, You probably haven’t that will do this, however I believe you have got could express the mind-set that many of people are in.

  • Just killing some in between class time on Digg and I found your article . Not usually what I want to read about, however it was absolutely worth my time. Thanks.

  • I just could not go away your site prior to suggesting that I extremely enjoyed the usual information a person supply for your guests? Is gonna be back continuously to inspect new posts

  • It a big idea! Just wanna say thank you for news you could have posted. Just continue composing this sort of post. I’m going to a loyal reader, thanks a lot.

  • I like the helpful info you provide in your articles.

    I’ll bookmark your weblog and check again here frequently. I am quite certain I’ll learn a lot of new stuff right here! Good luck for the next!

    Best Regards Nick

  • I had been very happy to locate this internet site.I really wanted to thank you for this cool read!! I definitely enjoying every part of it but i have you ever bookmarked to find new stuff from you post.

  • The sense of intending to assist, however not finding out how or the place, are some things a range of us have gone through.

  • I have learned newer and more effective things from a blog post. Also a thing to I have recognized is that usually, FSBO sellers will reject an individual. Remember, they will prefer to not ever use your products and services. But if you maintain a reliable, professional romance, offering guide and keeping contact for around four to five weeks, you will usually be able to win a business interview. From there, a listing follows. Cheers

  • Thank you for any other magnificent post. Where else may just anyone get that kind of information in such an ideal way of writing? I’ve a presentation subsequent week, and I’m at the search for such info.

  • I conceive you might have noted some really fascinating details , regards for the post.

  • Definitely, what splendid weblog and instructive posts, I surely can bookmark one’s internet site.Every one of the Best!

  • Definitely, such a splendid web site and instructive content, I definitely may bookmark one’s web page.All of the Best!

  • Definitely, such a tremendous site and instructive content, I definitely will bookmark your particular website or blog.All of the Best!

Leave a Reply

  

  

  

HTML Guide from Peachpit Press

$1.99 Web Hosting at Go Daddy 120x240
Apple-Computer-Sticker-Old

iPhoto 6

Apple-ID-Badge
Create Multiple Folders with Terminal

If you are more of a techy kind of person and are comfortable with using Terminal, here is a script you can use to easily create multiple folders:

First, for a single folder, type in: mkdir "Folder 1" --or whatever you want to name your folder, this creates a new directory, which, in effect is a new folder. To place multiple items in the 'Documents' folder: cd/Users/ Administrator/ Documents mkdir "Folder 1" "Folder 2" "Folder 3" To quickly create multiple folders, create a text file with the desired folder names (as many as you want) and name it something like 'folderList.txt'. Next type this in Terminal: cat folderList.txt |xargs mkdir Or you could create folders with the same prefix by entering: mkdir "Invoices " {"Corporate", "Individual", "Pro-Bono"}

AppleScript 1-2-3

Stop by every day to shop our new Deal of the Day at BarnesandNoble.com!

Add http://www.scriptsforapple.com to Technorati Favorites

Apple-iMac-Rainbow

Digg! Digg This!!

An AppleScript to Verify a Date

Run this in the Script Editor:

set dateRecord to (current date)
set defaultDate to (date string of dateRecord)
try
set apptDate to text returned of (display dialog "Enter appointment date:" default answer defaultDate buttons {"Set"} default button {"Set"})
set datetext to apptDate as text
date apptDate --if an invalid date is entered, the next dialog is aborted and it triggers the error alert below.
display dialog datetext & " is a valid date." with icon note buttons {"OK"} default button {"OK"}
on error
set alertText to "An error has occurred!"
set messageText to quote & datetext & quote & " is an invalid date."
display alert alertText message messageText as warning buttons {"OK"} default button "OK" giving up after 15
return
end try