AppleScript newbie seeks help

Hello,

I’ve got zippo AppleScript experience, and just a bit of BASIC programming from many years ago. I’m trying to figure out if it is possible to create a little AppleScript application that will do the following:

On opening, prompt me for an URL, then prompt me for a TITLE, then prompt me for a DESCRIPTION, then prompt me for a FILENAME, then save the information (with surrounding HTML) as an HTML file.

I’m trying to get a file that would look like this:

TITLE
DESCRIPTION which could be several sentences long, so would need a large entry box.

Then saved as FILENAME.html. (I’ll be editing the resulting files in BBEdit.)

Is this something that’s doable in AppleScript? (I hope I have explained everything clearly enough.)

Thanks for any help anyone can provide!
Bill

Hi Bill, and welcome.

Give script this a try:

set urlInput to text returned of (display dialog "Enter URL:" default answer "")
set titleInput to text returned of (display dialog "Enter Title:" default answer "")
set descriptionInput to text returned of (display dialog "Enter Description:" default answer return)

set htmlSource to "<dl>
	<dt><a href=\"" & urlInput & "\" target=\"_blank\">" & titleInput & "</a></dt>
	<dd>" & descriptionInput & "</dd>
</dl>"

set saveFile to choose file name with prompt "Save HTML file where?" default name "FILENAME.html"

try
	set saveFile to open for access saveFile with write permission
	write htmlSource to saveFile as string
	close access saveFile
on error errorMessage number errorNumber
	close access saveFile
	error "Error: " & errorNumber & return & errorMessage
end try

Fantastic! Thanks, very much! I never expected someone to actually write the script for me!

Best,
Bill

Good Job Qwerty! :cool:

Perhaps post this to Code Exchange? :wink:

Thanks Ray!

I’ll leave that choice up to Bill if he wants to. :slight_smile:

I just stumbled over Applescript.Net last week, so I’m not sure what Code Exchange is. It sounds like a place where scripts are shared, which would be fine with me if Qwerty doesn’t mind.

Do I need to do something to post it to Code Exchange?

  • Bill

Actually, Code Exchange is part of this forum.

When you come to the cover page on applescript.net, it will be the 6th category down.

Code Exchange

You need not do anything different other than give the topic an appropriate name, give it a good description and post Querty’s as he has.

Thanks!