Underline output and send email message.

I am trying to write a script to format your bibliography and copy it to the clipboard, which requires me to underline the title of the book, which I don’t know how to do.

I would also like to set an option to send me an email for expansion in two different places. not like a spammer, just open a message adressed to me, like a mailto: link in a web browser.

Finally, I would like to add a message to loop the script and process another set of data (without preserving the variable settings, obviously).

Here is my script, such as it is.

--This script will format your bibliography for you.
--
--This section asks you what format you want
set BibliographyFormat to (choose from list {"MLA", "APA", "Request..."} with prompt "What format will your Bibliography be?") as string
if BibliographyFormat is "MLA" then
	--This section asks what your source format is.
	set sourceFormat to (choose from list {"Single Author Book", "Multiple Author (up to 5) Book", "Book By Editor", "Newspaper", "Print Magazine", "Online Magazine", "Interview", "Website", "Request..."} with prompt "What format is your source?") as string
	if sourceFormat is "Single Author Book" then
		--This section asks for your information for a single author book
		--This asks the author name
		set authorName to (display dialog "Author Name" default answer "Last, First" buttons {"Next"} default button 1)
		if button returned of authorName is "Next" then
			set author to text returned in authorName
		end if
		--This asks the book's title.
		set bookTitle to (display dialog "Book Title" default answer "Title" buttons {"Next"} default button 1)
		if button returned of bookTitle is "Next" then
			set title to text returned in bookTitle
		end if
		--This asks the edition and sets the script to leave it out of the result if you don't input anything.
		set bookEdition to (display dialog "Book Edition- Leave Blank for First Edition" & return & "Ex: \"First\", not \"One\" or \"1\"" default answer "" buttons {"Next"} default button 1)
		if button returned of bookEdition is "Next" then
			set edition to text returned in bookEdition
			if text returned in bookEdition is "" then
				set editionYes to ""
			else
				set editionYes to " Edition. "
			end if
		end if
		--This asks the publishing city
		set publishCity to (display dialog "Publishing City" default answer "City" buttons {"Next"} default button 1)
		if button returned of publishCity is "Next" then
			set pCity to text returned in publishCity
		end if
		--This asks the publishing company
		set publishCompany to (display dialog "Publishing Company" default answer "Company" buttons {"Next"} default button 1)
		if button returned of publishCompany is "Next" then
			set pCompany to text returned in publishCompany
		end if
		--This asks the publishing date
		set publishDate to (display dialog "Publishing Date" default answer "Year" buttons {"Next"} default button 1)
		if button returned of publishDate is "Next" then
			set pDate to text returned in publishDate
		end if
		--This section formats the  information propely and copies it to the clipbooard
		--
		--
		--The Title variable is what I want underlined.
		set the clipboard to author & ". " & title & ". " & edition & editionYes & pCity & ": " & pCompany & ". " & pDate & "."
		--
		--
		--This is as far as I got. 
	else if sourceFormat is "Multiple Author (up to 5) Book" then
		-- item 2 action goes here
	else if sourceFormat is "Book By Editor" then
		-- item 3 action goes here
	else if sourceFormat is "Newspaper" then
		-- item 4 action goes here
	else if sourceFormat is "Print Magazine" then
		-- item 5 action goes here
	else if sourceFormat is "Online Magazine" then
		-- item 6 action goes here
	else if sourceFormat is "Interview" then
		-- item 7 action goes here
	else if sourceFormat is "Website" then
		-- item 8 action goes here
	else if sourceFormat is "Request..." then
		--
		--
		--This is the first part I want to open an email
		--
		--email "williewideweb@gmail.com" subject "More Bibliography Formats" body "This is the extra source format I want:"
	end if
else if BibliographyFormat is "APA" then
	-- item 2 action goes here
	
else if the button returned of the result is "Request..." then
	--
	--
	--This is the second part I want to open an email
	--
	--email "williewideweb@gmail.com" subject "More Bibliography Formats" body "This is the extra bibliography format I want:"
end if
--
--
--This part will ask you if you want to make another bibliography.
--
set startOver to (display dialog "Format another bibliography?" & return & return & "For another bibliography format, you need to rerun the script" buttons {"Yes, Same Source Format", "Yes, Different Source Format", "No, I'm Done"} default button 1)
if button returned of startOver is "Yes, Same Source Format" then
	--
	--
	--This is where I want it to loop to the first input box - these should help with that:
	if sourceFormat is "Single Author Book" then
		--return to Single Author Book
	else if sourceFormat is "Multiple Author (up to 5) Book" then
		--return to Multiple Author (up to 5) Book
	else if sourceFormat is "Book By Editor" then
		--return to Book By Editor
	else if sourceFormat is "Newspaper" then
		--return to Newspaper
	else if sourceFormat is "Print Magazine" then
		--return to Print Magazine
	else if sourceFormat is "Online Magazine" then
		--return to Online Magazine
	else if sourceFormat is "Interview" then
		--return to Interview
	else if sourceFormat is "Website" then
		--return to Website
	end if
else if button returned is "Yes, Different Source Format" then
	--return to "What format is your source?" list 
else if button returned is "No, I'm Done" then
	stop
end iff

It is extremely long, and will only get longer.

Thanks in advance- if you solve my problem i’ll let you have it for free (along with everybody else that wants it!) :wink:

Model: iMac G5 with iSight (Early 2006)
AppleScript: This is the Script Editor version, if that’s what Applescript version means: Version 2.1.1 (81). If it means what version my applescript is, then consider it 0.3
Browser: Safari 525.13
Operating System: Mac OS X (10.5)

Me again… I have updated this a lot. Here is the new version. I did not look to see if the comments made sense, so be aware.

--This script will format your bibliography for you.
--
--this alerts you that the script is in development
display dialog "This script is still in development. I am even less responsible for what it outputs than usually, which is not at all." buttons {"I Understand"} default button 1
--This section asks you what format you want
display dialog "For any format, do not include punctuation unless prompted." buttons {"I Understand"} default button 1
set BibliographyFormat to (choose from list {"MLA", "APA", "Request..."} with prompt "What format will your Bibliography be?") as string
if BibliographyFormat is "MLA" then
	--This section asks what your source format is.
	set sourceFormat to (choose from list {"Book", "Book By Editor", "Encyclopedia", "Print Magazine", "Newspaper", "Film & Video", "Sound Recording", "Interview", "Reviews", "Online Magazine", "Online Newspaper", "Website", "Request..."} with prompt "What format is your source?") as string
	if sourceFormat is "Book" then
		--This section asks for your information for a book
		--This asks the author name
		set authorName to (display dialog "Author Name (or Names)" & return & return & "For more than one name, preface the last one with \"and\"" default answer "Last, First" buttons {"Next"} default button 1)
		if button returned of authorName is "Next" then
			set author to text returned in authorName
		end if
		--This asks the book's title.
		set bookTitle to (display dialog "Book Title" default answer "Title" buttons {"Next"} default button 1)
		if button returned of bookTitle is "Next" then
			set title to text returned in bookTitle
		end if
		--This asks the edition and sets the script to leave it out of the result if you don't input anything.
		set bookEdition to (display dialog "Book Edition- Leave Blank for First Edition" & return & "Ex: \"First\", not \"One\" or \"1\"" default answer "" buttons {"Next"} default button 1)
		if button returned of bookEdition is "Next" then
			set edition to text returned in bookEdition
			if text returned in bookEdition is "" then
				set editionYes to ""
			else
				set editionYes to " Edition. "
			end if
		end if
		--This asks the publishing city
		set publishCity to (display dialog "Publishing City" default answer "City" buttons {"Next"} default button 1)
		if button returned of publishCity is "Next" then
			set pCity to text returned in publishCity
		end if
		--This asks the publishing company
		set publishCompany to (display dialog "Publishing Company" default answer "Company" buttons {"Next"} default button 1)
		if button returned of publishCompany is "Next" then
			set pCompany to text returned in publishCompany
		end if
		--This asks the publishing date
		set publishDate to (display dialog "Publishing Date" default answer "Year" buttons {"Next"} default button 1)
		if button returned of publishDate is "Next" then
			set pDate to text returned in publishDate
		end if
		--This section formats the  information propely and copies it to the clipbooard
		--The Title variable is what I want underlined.
		set the clipboard to author & ". " & title & ". " & edition & editionYes & pCity & ": " & pCompany & ". " & pDate & "."
		--
	else if sourceFormat is "Book By Editor" then
		--This section asks for your information for a book by an editor
		--This asks the editor name
		set editorName to (display dialog "Editor Name" default answer "Last, First" buttons {"Next"} default button 1)
		if button returned of editorName is "Next" then
			set editor to text returned in editorName
		end if
		--This asks the book's title.
		set bookTitle to (display dialog "Book Title" default answer "Title" buttons {"Next"} default button 1)
		if button returned of bookTitle is "Next" then
			set title to text returned in bookTitle
		end if
		--This asks the edition and sets the script to leave it out of the result if you don't input anything.
		set bookEdition to (display dialog "Book Edition- Leave Blank for First Edition" & return & "Ex: \"First\", not \"One\" or \"1\"" default answer "" buttons {"Next"} default button 1)
		if button returned of bookEdition is "Next" then
			set edition to text returned in bookEdition
			if text returned in bookEdition is "" then
				set editionYes to ""
			else
				set editionYes to " Edition. "
			end if
		end if
		--This asks the publishing city
		set publishCity to (display dialog "Publishing City" default answer "City" buttons {"Next"} default button 1)
		if button returned of publishCity is "Next" then
			set pCity to text returned in publishCity
		end if
		--This asks the publishing company
		set publishCompany to (display dialog "Publishing Company" default answer "Company" buttons {"Next"} default button 1)
		if button returned of publishCompany is "Next" then
			set pCompany to text returned in publishCompany
		end if
		--This asks the publishing date
		set publishDate to (display dialog "Publishing Date" default answer "Year" buttons {"Next"} default button 1)
		if button returned of publishDate is "Next" then
			set pDate to text returned in publishDate
		end if
		--This section formats the  information propely and copies it to the clipbooard
		--The Title variable is what I want underlined.
		set the clipboard to editor & ". " & title & ". " & edition & editionYes & pCity & ": " & pCompany & ". " & pDate & "."
	else if sourceFormat is "Newspaper" then
		--This section asks for your information for a newspaper
		--This asks the article's author's name
		set articleAuthor to (display dialog "Author of Article Name (or Names)" & return & return & "For more than one name, preface the last one with \"and\"" default answer "Last, First" buttons {"Next"} default button 1)
		if button returned of articleAuthor is "Next" then
			set author to text returned in articleAuthor
		end if
		--This asks the article's title
		set articleTitle to (display dialog "Title of Article" default answer "Title" buttons {"Next"} default button 1)
		if button returned of articleTitle is "Next" then
			set article to text returned in articleTitle
		end if
		--This asks the newspaper's title
		set paperTitle to (display dialog "Title of Newspaper" default answer "Title" buttons {"Next"} default button 1)
		if button returned of paperTitle is "Next" then
			set paper to text returned in paperTitle
		end if
		--this asks for the city of publication
		set publicationCity to (display dialog "City of Publication" & return & "Leave blank if city is in newspaper title." default answer "" buttons {"Next"} default button 1)
		if button returned of publicationCity is "Next" then
			set pCity to text returned in publicationCity
			if text returned in publicationCity is "" then
				set pCityBefore to ""
				set pCityAfter to ""
			else
				set pCityBefore to "("
				set pCityAfter to ") "
			end if
		end if
		--This asks the publishing date
		set publishDate to (display dialog "Publishing Date" default answer "Day Month, Year" buttons {"Next"} default button 1)
		if button returned of publishDate is "Next" then
			set pDate to text returned in publishDate
		end if
		--this sets the edition
		set paperEdition to (display dialog "Newspaper edition" & return & "Such as \"23\" not \"Twenty-Three\" or \"23rd\" or \"Twenty-Third\"" default answer "edition" buttons {"Next"} default button 1)
		if button returned of paperEdition is "Next" then
			set edition to text returned in paperEdition
		end if
		set pageNumber to (display dialog "For consecutive pages: first-last" & return & "For unconsecutive pages: first page+" default answer "#“# or #+" buttons {"Next"} default button 1)
		if button returned of pageNumber is "Next" then
			set pages to text returned in pageNumber
		end if
		--
		--This section formats the  information propely and copies it to the clipbooard
		--The paper variable is what I want underlined.
		set clipboard to author & " \"" & article & "\" " & paper & pCityBefore & pCity & pCityBefore & pDate & ", " & edition & ": " & pages & "."
	else if sourceFormat is "Encycopedia" then
		--This section asks for your information for an encyclopedia
		--this asks the author's name
		set authorName to (display dialog "Author Name (or Names)" & return & return & "For more than one name, preface the last one with \"and\"" default answer "Last, First" buttons {"Next"} default button 1)
		if button returned of authorName is "Next" then
			set author to text returned in authorName
		end if
		--This asks the article's title.
		set articleTitle to (display dialog "Title of Article" default answer "Title" buttons {"Next"} default button 1)
		if button returned of articleTitle is "Next" then
			set article to text returned in articleTitle
		end if
		--This asks the encyclopedia's name
		set encyclopediaName to (display dialog "Name of Encyclopedia" default answer "Name" buttons {"Next"} default button 1)
		if button returned of encyclopediaName is "Next" then
			set encyclopedia to text returned in encyclopediaName
		end if
		--This asks the edition
		set bookEdition to (display dialog "Encyclopedia Edition" & return & "\"First\", not \"One\" or \"1\"" default answer "" buttons {"Next"} default button 1)
		if button returned of bookEdition is "Next" then
			set edition to text returned in bookEdition
			set editionYes to " Edition. "
		end if
		--This asks the year
		set publishDate to (display dialog "Encyclopedia Year" default answer "Year" buttons {"Next"} default button 1)
		if button returned of publishDate is "Next" then
			set pDate to text returned in publishDate
		end if
		--This section formats the  information propely and copies it to the clipbooard
		--
		--
		--The encyclopedia variable is what I want underlined.
		set clipboard to author & ". \"" & article & ".\" " & encyclopedia & ". " & edition & editionYes & pDate & "."
	else if sourceFormat is "Print Magazine" then
		--This section asks for your information for a print magazine
		--This asks the author's name
		set authorName to (display dialog "Author Name (or Names)" & return & return & "For more than one name, preface the last one with \"and\"" default answer "Last, First" buttons {"Next"} default button 1)
		if button returned of authorName is "Next" then
			set author to text returned in authorName
		end if
		--This asks the article's title
		set articleTitle to (display dialog "Title of Article" default answer "Title" buttons {"Next"} default button 1)
		if button returned of articleTitle is "Next" then
			set article to text returned in articleTitle
		end if
		--This asks the newspaper's title
		set paperTitle to (display dialog "Title of Magazine" default answer "Title" buttons {"Next"} default button 1)
		if button returned of paperTitle is "Next" then
			set magazine to text returned in paperTitle
		end if
		--This asks the publishing date
		set publishDate to (display dialog "Publishing Date" default answer "Month Day, Year" buttons {"Next"} default button 1)
		if button returned of publishDate is "Next" then
			set pDate to text returned in publishDate
		end if
		--this sets the page numbers
		set pageNumber to (display dialog "For consecutive pages: first-last" & return & "For unconsecutive pages: first page+" default answer "#“# or #+" buttons {"Next"} default button 1)
		if button returned of pageNumber is "Next" then
			set pages to text returned in pageNumber
		end if
		--
		--This section formats the  information propely and copies it to the clipbooard
		--The magazine variable is what I want underlined.
		set clipboard to author & ". \"" & article & ".\" " & magazine & " " & pDate & ": " & pages & "."
	else if sourceFormat is "Online Magazine" then
		--This section asks for your information for an online magazine
		--This asks the author's name
		set authorName to (display dialog "Author Name (or Names)" & return & return & "For more than one name, preface the last one with \"and\"" default answer "Last, First" buttons {"Next"} default button 1)
		if button returned of authorName is "Next" then
			set author to text returned in authorName
		end if
		--This asks the article's title
		set articleTitle to (display dialog "Title of Article" default answer "Title" buttons {"Next"} default button 1)
		if button returned of articleTitle is "Next" then
			set article to text returned in articleTitle
		end if
		--This asks the newspaper's title
		set paperTitle to (display dialog "Title of Magazine" default answer "Title" buttons {"Next"} default button 1)
		if button returned of paperTitle is "Next" then
			set magazine to text returned in paperTitle
		end if
		--This asks the publishing date
		set publishDate to (display dialog "Publishing Date" default answer "Month Day, Year" buttons {"Next"} default button 1)
		if button returned of publishDate is "Next" then
			set pDate to text returned in publishDate
		end if
		--this sets the page numbers
		set pageNumber to (display dialog "For consecutive pages: first-last" & return & "For unconsecutive pages: first page+" & return & "If page numbers are not given, leave blank" default answer "" buttons {"Next"} default button 1)
		if button returned of pageNumber is "Next" then
			set pages to text returned in pageNumber
			if pages is not "" then
				set pageAfter to ". "
				set pageBefore to ": "
			else
				set pageAfter to ""
				set pageBefore to ". "
			end if
		end if
		--this sets the date of access
		set viewDate to (display dialog "Date you viewed this article" default answer "Month Day, Year" buttons {"Next"} default button 1)
		if button returned of viewDate is "Next" then
			set vDate to text returned in viewDate
		end if
		--this sets the URL
		set webAddress to (display dialog "URL of article (Web address)" default answer "http://www." buttons {"Next"} default button 1)
		if button returned of viewDate is "Next" then
			if webAddress is "http://www." then
				display dialog "That is not a valid web address" buttons {"OK"} default button 1
				set webAddress to (display dialog "URL of article (Web address)" default answer "http://www." buttons {"Next"} default button 1)
				set address to text returned in webAddress
			else
				set address to text returned in webAddress
			end if
		end if
		--This section formats the  information propely and copies it to the clipbooard
		--The magazine variable is what I want underlined.
		set clipboard to author & ". \"" & article & ".\" " & magazine & " " & pDate & pageBefore & pages & pageAfter & vDate & ". <" & address & ">"
	else if sourceFormat is "Interview" then
		-- look online for format explanation
	else if sourceFormat is "Website" then
		--this asks your information for a website
		--This asks the author's name
		set authorName to (display dialog "Author Name (or Names)" & return & return & "For more than one name, preface the last one with \"and\"" default answer "Last, First" buttons {"Next"} default button 1)
		if button returned of authorName is "Next" then
			set author to text returned in authorName
		end if
		--look online for format explanation
	else if sourceFormat is "Film & Video" then
		--this asks your information for a film or video
		--this asks the title
		set videoTitle to (display dialog "Title of the film" default answer "Title" buttons {"Next"} default button 1)
		if button returned of videoTitle is "Next" then
			set video to text returned in videoTitle
		end if
		--look online for format explanation
	else if sourceFormat is "Sound Recording" then
		-- item 8 action goes here
	else if sourceFormat is "Reviews" then
		-- item 8 action goes here
	else if sourceFormat is "Online Newspaper" then
		-- item 8 action goes here
	else if sourceFormat is "Request..." then
		--
		--
		--This is the second part I want to email me
		--
		--email "williewideweb@gmail.com" subject "More Bibliography Formats" body "This is the extra source format I want:"
	end if
end if
if BibliographyFormat is "APA" then
	-- item 2 action goes here
	
else if BibliographyFormat is "Request..." then
	--
	--
	--This is the third part I want to email me
	--
	--email "williewideweb@gmail.com" subject "More Bibliography Formats" body "This is the extra bibliography format I want:"
end if
--
--
--This part will ask you if you want to make another bibliography.
--
set startOver to (display dialog "Format another bibliography?" & return & return & "For another bibliography format, you need to rerun the script" buttons {"Yes, Same Source Format", "Yes, Different Source Format", "No, I'm Done"} default button 1)
if button returned of startOver is "Yes, Same Source Format" then
	--
	--
	--This is where I want it to loop to the first input box - these should help with that:
	if sourceFormat is "Single Author Book" then
		--return to Single Author Book
	else if sourceFormat is "Multiple Author (up to 5) Book" then
		--return to Multiple Author (up to 5) Book
	else if sourceFormat is "Book By Editor" then
		--return to Book By Editor
	else if sourceFormat is "Newspaper" then
		--return to Newspaper
	else if sourceFormat is "Print Magazine" then
		--return to Print Magazine
	else if sourceFormat is "Online Magazine" then
		--return to Online Magazine
	else if sourceFormat is "Interview" then
		--return to Interview
	else if sourceFormat is "Website" then
		--return to Website
	end if
else if button returned is "Yes, Different Source Format" then
	--return to "What format is your source?" list 
else if button returned is "No, I'm Done" then
	stop
end if
end

My first suggestion is go back through the code and refactor.

Refactoring your code is simply taking duplicate code and moving
it into a handler and then calling the handler from your code.

Here is an example. You have lots of display dialog’s throughout
your code so let’s move that into a handler. This way if you ever
want to add code to the display dialog’s you only have to change
that code in one place.

--call the handler like this
set {userResponse, buttonReturned} to getUserResponse("Enter your name", "", {"OK"}, 1)

--here is the handler
--I used the "to" instead of "on" only to make the code more "english" like
to getUserResponse(theMessage, defaultAnswer, buttonList, defaultButton)
	activate
	set {userResponse, buttonReturned} to {text returned, button returned} of ¬ 
	(display dialog theMessage default answer defaultAnswer buttons buttonList default button defaultButton)
	return {userResponse, buttonReturned}
end getUserResponsee

Now you try. Go through the code and find all the places with duplicate code
and refactor them into their own handler. If you write your handlers to
do simple task then they are usually more easily reusable. Just as in
the handler above. We are only getting the users response and button returned.
If we added in sending email or reading file info from that handler it would
become more complex and less reusable.

Another example from your code might be.


--current code
if button returned of bookEdition is "Next" then
	set edition to text returned in bookEdition
	if text returned in bookEdition is "" then
		set editionYes to ""
	else
		set editionYes to " Edition. "
	end if
end if


--Replace the above with the code below

--set a property for the "Next" button since it is used so often
property defaultButton : "Next" --properties go at the very top of your script


--call this handler in your code with
set editionYes to setTextReturned(buttonReturned, textReturned)


to setTextReturned(buttonReturned, textReturned)
	if buttonReturned is defaultButton then
		
		if textReturned is "" then
			set editionYes to ""
		else
			set editionYes to " Edition. "
		end if
	end if
	return editionYes
end setTextReturned

And remember, there is more than one way to skin a cat. I am also not an
expert on AppleScript. I am still learning like you. Reading some good books like,
“AppleScript - The Comprehensive Guide to Scripting and Automation on Mac OS X”
by Hanaan Rosenthal and then “AppleScript - The Definitive Guide” by Matt Neuburg
are a must for learning AppleScript. I have these two on my desk and reference them often.

hth,

Craig

Regards,

Craig

Faster replies using “Latest MacScripter Posts” :wink:
http://scriptbuilders.net/files/latestmacscripterposts1.0.html

Not sure I get this- a few more questions. Sorry.

  1. Should I create seperate handlers for each different box type? That seems easiest for me. Here is an example, I think.
--call it with:
set author to authorDialog

--set it with
on authorDialog
display dialog (display dialog "Author Name (or Names)" & return & return & "For more than one name, preface the last one with \"and\"" default answer "Last, First" buttons {"Next"} default button 1)
		if button returned of authorName is "Next" then
			set author to text returned in authorName
		end if

I’m pretty sure some of that is wrong- it just doesn’t make sense to me, as well as to Script Editor.

  1. Where do I put the handler “set” section? is it before or after the ‘body’ of the script?

That wasn’t too bad…

P.S. I couldn’t find those books at my local library ('s website), so I reserved AppleScript for Dummies and AppleScript : the missing manual.

Edit: I am reading something about handlers, and wondered if declaring author to be global would fix any problems.

Nobody likes me… they didn’t even remind me that I needed to close my handler, or tell me that I wasn’t calling it right.

I figgered it out on my own, so here’s the new (much shorter) script.

global sourceFormat
--this alerts you that the script is in development
display dialog "This script is still in development. I am even less responsible for what it outputs than usually, which is not at all." buttons {"I Understand"} default button 1
--This section asks you what format you want
display dialog "For any format, do not include punctuation unless prompted." buttons {"I Understand"} default button 1
set BibliographyFormat to (choose from list {"MLA", "APA", "Request..."} with prompt "What format will your Bibliography be?") as string
if BibliographyFormat is "MLA" then
	--This section asks what your source format is.
	set sourceFormat to (choose from list {"Book", "Encyclopedia", "Print Magazine", "Newspaper", "Film & Video", "Sound Recording", "Interview", "Reviews", "Online Magazine", "Online Newspaper", "Website", "Request..."} with prompt "What format is your source?") as string
	if sourceFormat is "Book" then
		--This section asks for your information for a book
		my dAuthor()
		my dTitle("Book")
		my dEdition()
		my dPCity()
		my dPCompany()
		my dPDate()
		--This section formats the  information propely and copies it to the clipbooard
		--The Title variable is what I want underlined.
		set the clipboard to author & ". " & title & ". " & edition & editionYes & pCity & ": " & pCompany & ". " & pDate & "."
		--
	else if sourceFormat is "Newspaper" then
		--This section asks for your information for a newspaper
		my dAuthor()
		my dTitle("Article")
		my dName("Newspaper")
		my dPCityNewspaper()
		my dPDateNewspaper()
		my dEdition()
		my dPages()
		--
		--This section formats the  information propely and copies it to the clipbooard
		--The paper variable is what I want underlined.
		set clipboard to author & " \"" & title & "\" " & sourceName & pCityBefore & pCity & pCityBefore & pDate & ", " & edition & ": " & pages & "."
	else if sourceFormat is "Encycopedia" then
		--This section asks for your information for an encyclopedia
		my dAuthor()
		my dTitle("Article")
		my dName("Encyclopedia")
		my dEdition()
		my dPDate()
		--
		--This section formats the  information propely and copies it to the clipbooard
		--The encyclopedia variable is what I want underlined.
		set clipboard to author & ". \"" & title & ".\" " & sourceName & ". " & edition & editionYes & pDate & "."
	else if sourceFormat is "Print Magazine" then
		--This section asks for your information for a print magazine
		my dAuthor()
		my dTitle("Article")
		my dName("Magazine")
		my dPDate()
		my dPages()
		--
		--This section formats the  information propely and copies it to the clipbooard
		--The magazine variable is what I want underlined.
		set clipboard to author & ". \"" & title & ".\" " & sourceName & " " & pDate & ": " & pages & "."
	else if sourceFormat is "Online Magazine" then
		--This section asks for your information for an online magazine
		my dAuthor()
		my dTitle("Article")
		my dName("Magazine")
		my dPDate()
		my dPages()
		my dVDate()
		my dURL()
		--
		--This section formats the  information propely and copies it to the clipbooard
		--The magazine variable is what I want underlined.
		set clipboard to author & ". \"" & title & ".\" " & sourceTitle & " " & pDate & pageBefore & pages & pageAfter & vDate & ". <" & address & ">"
	else if sourceFormat is "Interview" then
		-- look online for format explanation
	else if sourceFormat is "Website" then
		--this asks your information for a website
		--This asks the author's name
		my dAuthor()
		--look online for format explanation
	else if sourceFormat is "Film & Video" then
		--this asks your information for a film or video
		--this asks the title
		my dTitle("Film")
		--look online for format explanation
	else if sourceFormat is "Sound Recording" then
		-- item 8 action goes here
	else if sourceFormat is "Reviews" then
		-- item 8 action goes here
	else if sourceFormat is "Online Newspaper" then
		-- item 8 action goes here
	else if sourceFormat is "Request..." then
		--
		--
		--This is the second part I want to email me
		--
		--email "williewideweb@gmail.com" subject "More Bibliography Formats" body "This is the extra source format I want:"
	end if
end if
if BibliographyFormat is "APA" then
	-- item 2 action goes here
	
else if BibliographyFormat is "Request..." then
	--
	--
	--This is the third part I want to email me
	--
	--email "williewideweb@gmail.com" subject "More Bibliography Formats" body "This is the extra bibliography format I want:"
end if
--
--
--This part will ask you if you want to make another bibliography.
--
set startOver to (display dialog "Format another bibliography?" & return & return & "For another bibliography format, you need to rerun the script" buttons {"Yes, Same Source Format", "Yes, Different Source Format", "No, I'm Done"} default button 1)
if button returned of startOver is "Yes, Same Source Format" then
	--
	--
	--This is where I want it to loop to the first input box - these should help with that:
	if sourceFormat is "Single Author Book" then
		--return to Single Author Book
	else if sourceFormat is "Multiple Author (up to 5) Book" then
		--return to Multiple Author (up to 5) Book
	else if sourceFormat is "Book By Editor" then
		--return to Book By Editor
	else if sourceFormat is "Newspaper" then
		--return to Newspaper
	else if sourceFormat is "Print Magazine" then
		--return to Print Magazine
	else if sourceFormat is "Online Magazine" then
		--return to Online Magazine
	else if sourceFormat is "Interview" then
		--return to Interview
	else if sourceFormat is "Website" then
		--return to Website
	end if
else if button returned is "Yes, Different Source Format" then
	--return to "What format is your source?" list 
else if button returned is "No, I'm Done" then
	stop
end if
end



on dAuthor()
	--This asks the author name
	set author to text returned of (display dialog "Author or Editor Name (or Names)" & return & return & "For more than one name, preface the last one with \"and\"" default answer "Last, First" buttons {"Next"} default button 1)
	return author
end dAuthor

on dTitle(sourceKind)
	--This asks the book's title.
	set title to text returned of (display dialog sourceKind & " Title" default answer "Title" buttons {"Next"} default button 1)
	return title
end dTitle

on dName(sourceKind)
	--This asks the book's title.
	set sourceName to text returned of (display dialog sourceKind & " Title" default answer "Title" buttons {"Next"} default button 1)
	return sourceName
end dName

on dEdition()
	--This asks the edition and sets the script to leave it out of the result if you don't input anything.
	set bookEdition to (display dialog sourceFormat & " Edition- Leave Blank for First Edition" & return & "Ex: \"First\", not \"One\" or \"1\"" default answer "" buttons {"Next"} default button 1)
	if button returned of bookEdition is "Next" then
		set edition to text returned in bookEdition
		if text returned in bookEdition is "" then
			set editionYes to ""
		else
			set editionYes to " Edition. "
		end if
	end if
	return edition and editionYes
end dEdition

on dPCity()
	--This asks the publishing city
	set pCity to text returned of (display dialog "Publishing City" default answer "City" buttons {"Next"} default button 1)
	return pCity
end dPCity

on dPCompany()
	--This asks the publishing company
	set pCompany to text returned in (display dialog "Publishing Company" default answer "Company" buttons {"Next"} default button 1)
	return pCompany
end dPCompany

on dPDate()
	--This asks the publishing date
	set publishDate to text returned in (display dialog "Publishing Date" default answer "Year" buttons {"Next"} default button 1)
	return dPDate
end dPDate

on dPCityNewspaper()
	--this asks for the city of publication
	set pCity to text returned of (display dialog "City of Publication" & return & "Leave blank if city is in newspaper title." default answer "" buttons {"Next"} default button 1)
	if pCity is "" then
		set pCityBefore to ""
		set pCityAfter to ""
	else
		set pCityBefore to "("
		set pCityAfter to ") "
	end if
	return pCity and pCityBefore and pCityAfter
end dPCityNewspaper

on dPDateNewspaper()
	--This asks the publishing date
	set pDate to text returned of (display dialog "Publishing Date" default answer "Day Month, Year" buttons {"Next"} default button 1)
	return pDate
end dPDateNewspaper

on dPaperEdition()
	--this asks a newspaper's edition
	set edition to text returned of (display dialog "Newspaper edition" & return & "Such as \"23\" not \"Twenty-Three\" or \"23rd\" or \"Twenty-Third\"" default answer "##" buttons {"Next"} default button 1)
	return edition
end dPaperEdition

on dPages()
	--this asks for a page range
	set pages to text returned of (display dialog "Page Number(s)" & return & return & "For consecutive pages: first-last" & return & "For unconsecutive pages: first page+" default answer "#“# or #+" buttons {"Next"} default button 1)
	return pages
end dPages

on dVDate()
	--this sets the date of access
	set vDate to text returned of (display dialog "Date you viewed this article" default answer "Month Day, Year" buttons {"Next"} default button 1)
	return vDate
end dVDate

on dURL()
	--this sets the URL
	set address to text returned of (display dialog "URL of article (Web address)" default answer "http://www." buttons {"Next"} default button 1)
	if address is "http://www." then
		display dialog "That is not a valid web address" buttons {"OK"} default button 1
		set address to text returned of (display dialog "URL of article (Web address)" default answer "http://www." buttons {"Next"} default button 1)
	end if
	return address
end dURL

Additionally, about the books, I got- Applescript for Dummies was a disappointment- it was written back when system 7.5 was the new thing that not everyone had gotten yet. However, Applescript: The Missing Manual was pretty good. I have about every third page bookmarked for something I want to try.

And I now know that Author does not need to be global, it needs to be returned.