Sorry Andreas,
I am not dead, I just got busy at work. I appreciate all of your help.
I am still having the problem. The sample script I posted was only the first section of the script. If I use your fix on just that section I works fine, but the next subroutine continues and I get the above mentioned error. I am a beginner at apple script as you can tell and not an expert on subroutines. If you could take a look at my entire script below and give any suggestions I would appreciate it. I would like the cancel button end the script with no error messages on any window in the script regardless if all of the variable have been defined or not.
Thank you,
Damon
set Language to DoMenu(["English", "French", "German", "Spanish"]) -- "Italian", "Japanese" to be added
on DoMenu(theLanguage)
set [_next, _cancel, _choice] to dd auto dialog {size:[390, 240], contents:[¬
{class:push button, bounds:[320, 210, 380, 230], name:"Next"}, ¬
{class:push button, bounds:[240, 210, 300, 230], name:"Cancel"}, ¬
{class:radio group, bounds:[10, 45, 130, 61], button offset:[120, 50], max down:3, contents:theLanguage}, ¬
{class:static text, bounds:[10, 10, 250, 26], contents:"Choose an Language:"} ¬
], timeout after:200000} with grayscale
if _next then
return theLanguage's item _choice
else if _cancel then
tell me to quit
end if
if Language is "English" then
set lang to "En"
else if Language is "French" then
set lang to "FR"
else if Language is "Italian" then
set lang to "IT"
else if Language is "German" then
set lang to "GR"
else if Language is "Spanish" then
set lang to "SP"
else if Language is "Japanese" then
set lang to "JP"
end if
end DoMenu
if Language is "English" then
set OSchoice to (["9.1"])
else if Language is "French" then
set OSchoice to (["9.1", "9.2", "10.1"])
else if Language is "Italian" then
set OSchoice to (["9.1", "9.2"])
else if Language is "German" then
set OSchoice to (["10.1"])
else if Language is "Spanish" then
set OSchoice to (["9.1"])
else if Language is "Japanese" then
set OSchoice to (["9.1"])
end if
set OS to DoMenu2(OSchoice)
on DoMenu2(theOS)
set [_next, _cancel, _choice] to dd auto dialog {size:[390, 240], contents:[¬
{class:push button, bounds:[320, 210, 380, 230], name:"Next"}, ¬
{class:push button, bounds:[240, 210, 300, 230], name:"Cancel"}, ¬
{class:radio group, bounds:[10, 45, 130, 61], button offset:[120, 50], max down:2, contents:theOS}, ¬
{class:static text, bounds:[10, 10, 250, 26], contents:"Choose an OS version:"} ¬
], timeout after:200000} with grayscale
if _next then
return theOS's item _choice
else if _cancel then
tell me to quit
end if
end DoMenu2
set apps to DoMenu3(["With Applications", "Without Applications"])
if apps is "With Applications" then
set wapps to "WA"
else if apps is "Without Applications" then
set wapps to "NA"
end if
on DoMenu3(theApps)
set [_next, _cancel, _choice] to dd auto dialog {size:[390, 240], contents:[¬
{class:push button, bounds:[320, 210, 380, 230], name:"Next"}, ¬
{class:push button, bounds:[240, 210, 300, 230], name:"Cancel"}, ¬
{class:radio group, bounds:[50, 80, 300, 95], button offset:[120, 50], max down:2, contents:theApps}, ¬
{class:static text, bounds:[10, 10, 250, 26], contents:"Choose With or Without Applications:"} ¬
], timeout after:200000} with grayscale
if _next then
return theApps's item _choice
else if _cancel then
tell me to quit
end if
end DoMenu3
set excludeDisks to {"Mac Images v1.1", "Mac_OS_Scripts", "Mac_OS_Images"}
tell application "Finder" to set dlist to (name of every disk whose name is not in excludeDisks) as list
set diskq to DoMenu4(dlist)
on DoMenu4(thediskq)
set [_next, _cancel, _choice] to dd auto dialog {size:[390, 240], contents:[¬
{class:push button, bounds:[320, 210, 380, 230], name:"Next"}, ¬
{class:push button, bounds:[240, 210, 300, 230], name:"Cancel"}, ¬
{class:radio group, bounds:[10, 45, 130, 61], button offset:[120, 50], max down:3, contents:thediskq}, ¬
{class:static text, bounds:[10, 10, 250, 26], contents:"Choose a Volume:"} ¬
], timeout after:200000} with grayscale
if _next then
return thediskq's item _choice
else if _cancel then
tell me to quit
end if
end DoMenu4
set imagestring to "MAC_OS_IMAGES:MacOS9.1:" & lang & OS & wapps & ".img"
set tWhatToRestore to imagestring
set tWhereToRestore to "" & diskq & ":"
launch application "Apple Software Restore"
tell application "Apple Software Restore"
with timeout of 1000000 seconds
try
Restore tWhatToRestore to ¬
tWhereToRestore placing in entire volume ¬
preprocess erasing disk ¬
copying everything ¬
warning true ¬
barber pole speed 10 without checksum, removing unwanted files and erasing on failure
on error tErrorMessage number tErrorNumber
display dialog ("Error: " & "[" & tErrorMessage & "]" & ", [" & tErrorNumber & "]")
end try
end timeout
quit
end tell
tell application "Finder"
set startupDisk to name of startup disk
set theDisks to every disk whose (name is not startupDisk and ejectable is true)
repeat with x in theDisks
set diskName to name of x
try
put away disk diskName
end try
end repeat
end tell
if imagestring is "MAC_OS_IMAGES:MacOS9.1:En9.1WA.img" then
set Imagechoice to "English 9.1"
--else if imagestring is "Fr9.1WA.img" then
--set Imagechoice to (["French 9.1"])
--else if imagestring is "It9.1WA.img" then
--set Imagechoice to (["Italian 9.1"])
--else if imagestring is "Gr9.1WA.img" then
--set Imagechoice to (["german 9.1"])
--else if imagestring is "Sp9.1WA.img" then
--set Imagechoice to (["Spanish 9.1"])
--else if imagestring is "Jp9.1WA.img" then
--set Imagechoice to (["Japanese 9.1"])
end if
tell application "Finder"
activate
select disk Imagechoice
open selection
close container window of disk Imagechoice
end tell
set timagechoice to "" & Imagechoice & ":"
tell application "Startup Disk"
activate
set startup disk alias to alias timagechoice
quit
end tell
tell application "Finder"
restart
end tell