-- Disk image chooser application for Basilisk II or SheepShaver
-- by Edward Mendelson, based partly on code by many, many other people
-- version 1.3 -- 30 August 2009
global appName
set appName to "Basilisk II"
-- AppName must be either "Basilisk II" or "SheepShaver"
global actionCount, additionalListText
global cancelName, cdBootNumber, cdFileFlag, cdStateVerb, cdWriteFlag, currentCount, currentDisks
global dupeRemoved
global fileDisks, firstDisk, firstFolder, firstPath, firstUnix
global listDisks, listOpts
global msgTitle
global optionText
global prefsUnixFile
global bulletList
global undupList
global listError
global badDiskPath
set listError to 0
global cancelOut
set cancelOut to 0
global addOpt, bcdOpt, createOpt, remOpt, setOpt
set addOpt to "Add an existing disk image to" & space & appName & space & "system"
set bcdOpt to "Boot" & space & appName & space & "from CD-ROM if present (enable/disable)"
set createOpt to "Create a new blank disk image for" & space & appName & space & "system"
set remOpt to "Remove a disk image from" & space & appName & space & "system"
set setOpt to "Set a different startup disk image for" & space & appName & space & "system"
set actionCount to 0
set dupeRemoved to 0
set bulletList to ""
set {msgTitle, prefsUnixFile} to appCheck(appName)
testOthers()
readPrefs()
getDetails()
specifyActions()
-- error number -128
-- Subroutines below --
on readPrefs() -- use grep to get data from prefs file
try
do shell script "cp ~/." & prefsUnixFile & space & "~/.PrefsFileBackup"
on error
set dialogText to "Error reading preferences file. Quitting."
errorQuit(dialogText, msgTitle)
end try
try
set currentDisks to do shell script "grep '^disk ' ~/." & prefsUnixFile & " | sed 's/^disk //'"
on error
set dialogText to "Error reading preferences file. Quitting."
errorQuit(dialogText, msgTitle)
end try
set cdFileFlag to "off"
set cdWriteFlag to "off"
try
set cdBootNumber to do shell script "grep '^bootdriver ' ~/." & prefsUnixFile & " | sed 's/^bootdriver //'"
if cdBootNumber is equal to "-62" then -- minus-62 is CD-ROM driver, 0 is default
set cdFileFlag to "on"
set cdWriteFlag to "on"
end if
end try
set testDisks to every paragraph of currentDisks
repeat with theItem in testDisks
try
set theAlias to POSIX file (theItem) as alias
on error
set badDiskPath to contents of theItem
set contents of theItem to theItem & space & "(file or path not found!)"
end try
end repeat
set oTD to AppleScript's text item delimiters
set text item delimiters to return
set AppleScript's text item delimiters to oTD
set fileDisks to testDisks -- this is permanent record of prefs file
copy fileDisks to listDisks -- this changes each time
end readPrefs
on getDetails()
if the number of items in listDisks is equal to 0 then
set firstDisk to "none"
set firstUnix to POSIX path of (path to home folder)
set firstPath to firstUnix as string
end if
if the number of items in listDisks is greater than 0 then
tell application "Finder" to set firstFolder to (path to home folder) as alias
set firstDisk to (item 1 of listDisks) as string
set firstUnix to POSIX file firstDisk
if listError = 1 then
else
try
set firstPath to alias firstUnix as string
on error
if "/" is in badDiskPath then
set warningText to "It may have been moved, renamed or deleted."
else
set warningText to "The full path is not listed, perhaps because the file is in the same folder with the" & space & appName & space & "application."
end if
set dialogText to "Unable to find the startup disk image:" & return & return & badDiskPath & return & return & warningText & return & return & "Please use the menus in this script to remove any invalid paths."
set buttonList to {"Quit", "Continue"}
set defBtn to 2
set userChoice to userMsg(dialogText, buttonList, defBtn)
if userChoice = false then
error number -128
end if
if userChoice = "Quit" then
error number -128
end if
if userChoice = "Continue" then
set firstDisk to "unknown"
set firstUnix to POSIX path of (path to home folder)
set firstPath to (path to home folder) as string
tell application "Finder" to set firstFolder to (path to home folder) as alias
set listError to 1
end if
end try
end if
if listError = 0 then
tell application "Finder" to set firstFolder to (container of file firstPath) as alias
end if
end if
set stringDelim to (return & "•" & space) -- generate bulleted list of disks to use in dialogs
listToString(listDisks, stringDelim)
set bulletList to "•" & space & bulletList & return
set additionalListText to bulletList
end getDetails
on specifyActions()
my getDetails()
if fileDisks = listDisks then -- keep track of changes
set actionCount to 0
end if
if cdFileFlag is not equal to cdWriteFlag then
set actionCount to actionCount + 1
end if
set currentCount to number of items in listDisks
set optionText to ""
if currentCount = 0 then
set dialogText to "You have no disks installed in your" & space & appName & space & "setup. You should now add or create a new disk; you may add further disks in a later step."
set listOpts to {addOpt, bcdOpt, createOpt}
end if
if currentCount is greater than 0 then
if currentCount = 1 then
set diskNumText to "disk named below (if bootable):"
set listOpts to {addOpt, bcdOpt, createOpt, remOpt}
else
set diskNumText to "first bootable disk in this list:"
set listOpts to {addOpt, bcdOpt, createOpt, remOpt, setOpt}
end if
set optionText to return & "Select an action from the choices below:"
set dialogText to "The current" & space & appName & space & "startup disk is the" & space & diskNumText & return & return & additionalListText & optionText -- "•" & space & firstDisk & return & --removed before addlListText!
end if
if actionCount is greater than 0 then
set cancelName to "Write or abandon changes"
else
set cancelName to "Exit"
end if
my optionList(listOpts, dialogText, cancelName)
end specifyActions
on optionList(listOpts, dialogText, cancelName)
tell me to activate
if listError = 1 then
set firstOpt to remOpt
else
set firstOpt to addOpt
end if
try
set userOptItem to choose from list listOpts with prompt dialogText OK button name "Select" cancel button name cancelName default items firstOpt with title msgTitle
end try
if userOptItem is false then
if actionCount is greater than 0 then
my writePrefs()
else
error number -128
end if
end if
set userOpt to word 1 of (userOptItem as string)
if userOpt = "Add" then
my addDisk()
end if
if userOpt = "Boot" then
my bootCD()
end if
if userOpt = "Create" then
my createDisk()
end if
if userOpt = "Remove" then
my removeDisk()
end if
if userOpt = "Set" then
my setStart()
end if
end optionList
on addDisk()
set dupeRemoved to 0
set chooseDisk to my getDisk(firstDisk, firstUnix, bulletList)
set newAddDisk to chooseDisk as string
set end of listDisks to newAddDisk
set newList to listDisks
--display dialog "New list is: " & newList as string
set undupList to my removeDuplicates(newList, newAddDisk)
set newList to undupList
if dupeRemoved = 1 then
set listDisks to newList
my specifyActions()
end if
set actionCount to actionCount + 1
if number of items in newList is greater than 1 then
set introText to "You have added the disk" & return & return & "•" & space & newAddDisk & return & return
set startList to newList
try
set movedList to my moveToFirst(startList, introText)
on error number errorNum
-- display dialog "Error number: " & errorNum
if errorNum = -128 then -- set cancelOut to 1
-- if cancelOut = 1 then
error number -128
end if
display dialog "An unknown error occurred. Please try again. It may work the next time."
my specifyActions()
end try
set currentCount to number of items in movedList
set listDisks to movedList
else
set listDisks to newList
end if
-- my getDetails()
set actionCount to actionCount + 1
my specifyActions()
end addDisk
on bootCD()
set addBcdText to ""
if cdFileFlag = cdWriteFlag then
if cdFileFlag = "off" then
set cdVerb to "Enable"
set addCdText to "OFF (disabled)."
set buttonList to {"Enable this option", "Keep setting in preference file"}
else
set cdVerb to "Disable"
set addCdText to "ON (enabled)."
set buttonList to {"Disable this option", "Keep setting in preference file"}
end if
end if
tell me to activate
if cdFileFlag is not equal to cdWriteFlag then
if (cdWriteFlag = "on" and cdFileFlag = "off") then
set addBcdText to return & return & "You have already chosen to enable this option when I write a new preference file to disk. Do you want to change your mind, and leave this option disabled, as in the existing preference file?"
set cdVerb to "Disable"
set addCdText to "OFF (disabled)."
set buttonList to {"Continue to enable this option", "Keep setting in preference file"}
end if
if (cdWriteFlag = "off" and cdFileFlag = "on") then
set addBcdText to return & return & "You have already chosen to disable this option when I write a new preference file to disk. Do you want to change your mind and leave this option enabled, as in the existing preference file?"
set cdVerb to "Enable"
set addCdText to "ON (enabled)."
set buttonList to {"Continue to disable this option", "Keep setting in preference file"}
end if
end if
set dialogText to cdVerb & space & "the option to boot from a CD-ROM (if present)? In the preference file on disk, this option is currently turned" & space & addCdText & return & return & "With this option turned on," & space & appName & space & "will boot from a CD-ROM if a CD-ROM is present, and from the first bootable disk image file if no CD-ROM is present." & addBcdText
set defBtn to 2
try
set userChoice to my userMsg(dialogText, buttonList, defBtn)
on error
my specifyActions()
end try
if cdFileFlag = "on" then
set cdStateVerb to "on (enabled)."
end if
if cdFileFlag = "off" then
set cdStateVerb to "off (disabled)."
end if
tell me to activate
if cdWriteFlag = cdFileFlag then
if userChoice = "Enable this option" then
display dialog "The option to boot from the CD-ROM will be turned on (enabled) when changes to the preferences file are written to disk." buttons {"OK"} default button 1 with title msgTitle
set cdWriteFlag to "on"
set actionCount to actionCount + 1
end if
if userChoice = "Disable this option" then
display dialog "The option to boot from the CD-ROM will be turned off (disabled) when changes to the preferences file are written to disk." buttons {"OK"} default button 1 with title msgTitle
set cdWriteFlag to "off"
set actionCount to actionCount + 1
end if
if userChoice = "Keep setting in preference file" then
display dialog "No change will be made to the preference file. The option to boot from a CD-ROM if present will remain" & space & cdStateVerb buttons {"OK"} default button 1 with title msgTitle
end if
else
-- the next if line (and the matching end if) are not needed, but are here to clarify the logic
if cdWriteFlag is not equal to cdFileFlag then
if userChoice = "Continue to enable this option" then
display dialog "As previously chosen, the option to boot from the CD-ROM will be turned on (enabled) when changes to the preferences file are written to disk." buttons {"OK"} default button 1 with title msgTitle
set cdWriteFlag to "on"
end if
if userChoice = "Disable this option" then
display dialog "As previously chosen, the option to boot from the CD-ROM will be turned off (disabled) when changes to the preferences file are written to disk." buttons {"OK"} default button 1 with title msgTitle
end if
if userChoice = "Keep setting in preference file" then
display dialog "No change will be made to the preference file. The option to boot from a CD-ROM if present will remain" & space & cdStateVerb buttons {"OK"} default button 1 with title msgTitle
if cdWriteFlag = "on" then
set cdWriteFlag to "off"
else
set cdWriteFlag to "on"
end if
set actionCount to actionCount - 1
end if
end if
end if
my specifyActions()
end bootCD
on createDisk()
set displayString to "Please select a size for your new disk in megabytes:"
set defaultNumber to 256
repeat
try
tell me to activate
set createSize to (display dialog displayString default answer defaultNumber with title msgTitle)
on error
my specifyActions()
end try
try
set mbNumber to (text returned of createSize) as number
set createSize to (text returned of createSize) as string
exit repeat
on error errstr
set displayString to "Please enter numbers only. You entered:"
set defaultNumber to text returned of createSize
end try
end repeat
set createNumber to (mbNumber * 2048) as string
(* -- this is for .dmg files only
repeat
try
tell me to activate
display dialog "Enter the name that will appear beneath the icon for your new disk:" default answer "Untitled" with title msgTitle
on error
my specifyActions()
end try
if text returned of result is not equal to "" then
set createName to text returned of result
exit repeat
end if
end repeat
*)
tell me to activate
try
set newImageFile to choose file name with prompt "Choose a name and location for your new disk image file." default name "New" & createSize & "MB.dsk" default location firstFolder
on error
my specifyActions()
end try
if newImageFile = false then
my createDisk()
end if
set newImagePosix to POSIX path of newImageFile as Unicode text
try
tell me to activate
display dialog "This will take up to a minute. Please click OK and then wait patiently for the next message." with title msgTitle
on error
my specifyActions()
end try
try
-- display dialog newImageFile & space & createNumber
do shell script "dd if=/dev/zero of=" & quoted form of newImagePosix & space & "count=" & createNumber
-- do shell script "hdiutil create -megabytes" & space & createSize & space & "-fs HFS -volname" & space & quoted form of createName & space & "-o" & space & quoted form of newImagePosix & space & "-ov"
on error
tell me to activate
display dialog "Error creating image file." buttons {"OK"} default button 1 with title msgTitle
my specifyActions()
end try
set dialogText to "Do you want to add this newly-created image file to your" & space & appName & space & "system?" & return & return & newImagePosix
set buttonList to {"Do not add to system", "Add to system"}
set defBtn to 2
set userChoice to my userMsg(dialogText, buttonList, defBtn)
if userChoice = "Do not add to system" then
tell me to activate
display dialog "The new disk image will not be added to the list in the preference file on disk. You may use this program to add it later." buttons {"OK"} default button 1 with title msgTitle
end if
if userChoice = "Add to system" then
set end of listDisks to newImagePosix
set actionCount to actionCount + 1
end if
my specifyActions()
end createDisk
on removeDisk()
my getDetails()
set removeList to listDisks
set addRemoveText to ""
set markItem to ""
if the number of items in removeList is 0 then
tell me to activate
display dialog "There are no disks installed in your" & space & appName & space & "system. Please add a disk to the system before making any further changes." buttons {"OK"} default button 1 with title msgTitle
my specifyActions()
end if
if the number of items in removeList is 1 then
set addRemoveText to return & return & "Warning: the" & space & appName & space & "system will not run if you remove the only disk. If you remove this disk, you must add another before writing the changes to the preferences file."
set markItem to {item 1 in removeList}
end if
tell me to activate
set cutDisk to (choose from list removeList with prompt "Select the disk image file to remove from the" & space & appName & space & "system by clicking on it so that its name is highlighted. (The actual file will not be deleted from your OS X disk.)" & addRemoveText OK button name "Remove" default items markItem) as text
-- add error handler here?
set shorterList to my removeFromList(cutDisk, removeList)
set listDisks to shorterList
if fileDisks = listDisks then
else
set actionCount to actionCount + 1
end if
my specifyActions()
end removeDisk
on setStart()
my getDetails()
set introText to ""
set startList to listDisks
try
set movedList to my moveToFirst(startList, introText)
on error
my specifyActions()
end try
set listDisks to movedList
if startList = movedList then
set dialogText to "Selected startup disk is the same as the current startup disk." & return & return & "No change made to list."
set buttonList to {"OK"}
set defBtn to 1
my userMsg(dialogText, buttonList, defBtn)
else
set actionCount to actionCount + 1
end if
my getDetails()
my specifyActions()
end setStart
on writePrefs()
set noDiskChange to "yes"
if fileDisks = listDisks then
else
set noDiskChange to "no"
set addWriteText to ""
if cdFileFlag = cdWriteFlag then
else
set addWriteText to return & "The option to boot from CD-ROM (if present) will also be turned" & space & cdStateVerb
end if
if the number of items in listDisks is greater than 1 then
set textPlural to "s:"
else
set textPlural to ":"
end if
set dialogText to "You are about to write a new" & space & appName & space & "preference file listing the following disk image" & textPlural & return & return & bulletList & addWriteText
set buttonList to {"Cancel and exit", "Return to main menu", "Write preference file"}
set defBtn to 3
set userChoice to my userMsg(dialogText, buttonList, defBtn)
if userChoice = false then
error number -128
end if
if userChoice = "Cancel and exit" then
set cancelOut to 1
set dialogText to "Program cancelled."
my cancelQuit(dialogText, msgTitle)
error number -128
end if
if userChoice = "Return to main menu" then
my specifyActions()
end if
if userChoice = "Write preference file" then
do shell script "grep -v ^disk ~/." & prefsUnixFile & " > ~/.prefFileTemp"
repeat with theCurrentDisk in listDisks
if "(file or path not found!)" is in theCurrentDisk then
set the contents of theCurrentDisk to text 1 thru ((offset of "(" in theCurrentDisk) - 1) of theCurrentDisk
end if
do shell script "echo disk" & space & theCurrentDisk & space & ">> ~/.prefFileTemp"
end repeat
try
do shell script "mv ~/.prefFileTemp ~/." & prefsUnixFile
on error
set dialogText to "Problem writing new preferences file. Changes to list of disks not made."
errorQuit(dialogText, msgTitle)
end try
end if
end if
if cdFileFlag = cdWriteFlag then
else
if noDiskChange = "yes" then
set dialogText to "You are about to write a new" & space & appName & space & "preference file in which the option to boot from a CD-ROM (if present) will be switched" & space & cdStateVerb
set buttonList to {"Return to main menu", "Write new preference file"}
set defBtn to 2
set userChoice to my userMsg(dialogText, buttonList, defBtn)
if userChoice = "Write new preference file" then
else
my specifyActions()
end if
end if
if cdWriteFlag = "off" then
set cdNumber to "0"
else
set cdNumber to "-62"
end if
do shell script "grep -v ^bootdriver ~/." & prefsUnixFile & " > ~/.prefFileTemp"
do shell script "echo bootdriver" & space & cdNumber & space & ">> ~/.prefFileTemp"
try
do shell script "mv ~/.prefFileTemp ~/." & prefsUnixFile
on error
set dialogText to "Problem writing new preferences file. CD-ROM boot option not set."
errorQuit(dialogText, msgTitle)
end try
end if
set dialogText to "Preferences file written correctly. Launch" & space & appName & ", return to main menu, or Exit?" & return & return & "(If you choose to Launch" & space & appName & ", I will try to run Exposé briefly in order to clear screen artifacts that may appear. Your desktop will return to normal within two or three seconds.)"
set buttonList to {"Launch" & space & appName, "Return to main menu", "Exit"}
set defBtn to 3
set userChoice to my userMsg(dialogText, buttonList, defBtn)
if userChoice = "Exit" then
error number -128
end if
if userChoice = ("Launch" & space & appName) then
try
if appName = "Basilisk II" then
set appRun to "BasiliskII"
else
set appRun to "SheepShaver"
end if
tell application appRun to activate
try
my launchExpose()
on error
try
my runExpose()
end try
end try
on error
set dialogText to "Could not launch" & space & appName & ". Sorry."
my errorQuit(dialogText, msgTitle)
end try
error number -128
end if
if userChoice = "Return to main menu" then
set actionCount to 0
my readPrefs()
my specifyActions()
end if
end writePrefs
on appCheck(appName)
global msgTitle
if (appName = "Basilisk II" or appName = "SheepShaver") then
set msgTitle to "Choose Disk Images for" & space & appName
if appName = "Basilisk II" then
set prefsUnixFile to "basilisk_ii_prefs"
end if
if appName = "SheepShaver" then
set prefsUnixFile to "sheepshaver_prefs"
end if
return {msgTitle, prefsUnixFile}
else
set msgTitle to "Disk Image Chooser for Emulators"
set dialogText to "Application name must be either Basilisk II or SheepShaver"
my errorQuit(dialogText, msgTitle)
end if
end appCheck
on getDisk(firstDisk, firstUnix, bulletList)
tell me to activate
try
set chooseAlias to choose file default location firstUnix with prompt "Choose a disk image file to add to the" & space & appName & space & "system. Already installed:" & return & return & bulletList without invisibles
tell (info for chooseAlias without size) to set {aliasName, aliasExt} to {name, name extension}
tell application "Finder"
set aliasType to file type of chooseAlias
-- display dialog ("aliasType: " & aliasType as string) & " and also aliasExt: " & aliasExt
set extList to {"dsk", "img", "image", "dmg", "hfv"}
set typeList to {"devr", "dimg", "DMd3", "DDim", "dImg"}
if aliasExt is in extList then
else
if aliasType is in typeList then
else
set dialogText to ("You have selected the file:" & return & return & POSIX path of chooseAlias as string) & return & return & "Are you sure this is a disk image file?"
set buttonList to {"Yes, this is a disk image", "No, this is not a disk image"}
set defBtn to 2
set userChoice to my userMsg(dialogText, buttonList, defBtn)
if userChoice = "No, this is not a disk image" then
my specifyActions()
end if
end if
end if
end tell
on error
my specifyActions()
end try
if chooseAlias = "" then
my specifyActions()
end if
global chooseDisk
set chooseDisk to POSIX path of chooseAlias as string
-- display dialog chooseDisk as string
return chooseDisk
end getDisk
on removeDuplicates(newList, newAddDisk)
set undupList to {}
set firstCount to number of items in newList
repeat with an_item in newList
if undupList does not contain an_item then set end of undupList to (contents of an_item)
end repeat
set secondCount to number of items in undupList
if firstCount = secondCount then
else
tell me to activate
display dialog "The disk image that you chose is already in the system:" & return & return & newAddDisk buttons {"OK"} default button 1 with title msgTitle
set dupeRemoved to 1
end if
return undupList
end removeDuplicates
on moveToFirst(startList, introText)
if number of items in startList is greater than 1 then
set startText to "first bootable disk in the list below."
else
set startText to "disk listed below (if bootable)."
end if
tell me to activate
set newFirst to (choose from list startList with prompt introText & "Select a startup disk for the" & space & appName & space & "system." & return & return & "The current startup disk is the" & space & startText OK button name "Select" cancel button name "No change" default items {item 1 in startList}) as text
set tDO to AppleScript's text item delimiters
set fixList to startList
if newFirst is not equal to "false" then
set myDelimiter to character id 5
set AppleScript's text item delimiters to {myDelimiter}
set startstring to startList as string
set AppleScript's text item delimiters to {myDelimiter & newFirst & myDelimiter}
set fixList to (text items of (myDelimiter & startstring & myDelimiter))
set newString to newFirst & (item 1 of fixList) & myDelimiter & (item 2 of fixList)
set AppleScript's text item delimiters to {myDelimiter}
set fixList to reverse of (rest of (reverse of (text items of newString)))
else
set changeCancelled to 1
my specifyActions()
end if
set AppleScript's text item delimiters to {return}
set AppleScript's text item delimiters to tDO
set movedList to fixList
return movedList
end moveToFirst
on removeFromList(theItem, aList)
set shorterList to {}
repeat with x in aList
if x as string is not equal to theItem as string then
set shorterList to shorterList & x
end if
end repeat
return shorterList
end removeFromList
on userMsg(dialogText, buttonList, defBtn)
tell me to activate
try
display dialog dialogText buttons buttonList default button defBtn with icon note with title msgTitle
on error
my specifyActions()
end try
set userChoice to button returned of result
if userChoice = "Quit" then
error number -128
end if
return userChoice
end userMsg
on listToString(theList, stringDelim)
set oTD to AppleScript's text item delimiters
set AppleScript's text item delimiters to stringDelim
global bulletList
set bulletList to theList as string
if bulletList = "" then
set bulletList to "None (boot from CD-ROM only)"
end if
set AppleScript's text item delimiters to oTD
return bulletList
end listToString
on runExpose()
-- attempt to run Exposé to clear up screen artifacts
set fcode to ""
tell application "System Events"
tell expose preferences
try
set fcode to (get function key of application windows shortcut) as string
--set fKeyMod to (get function key modifiers of application windows shortcut) as string
end try
end tell
end tell
if fcode is not equal to "" then
set kcode to my getkcode(fcode)
-- delay 1
try
tell application "System Events"
key code kcode
delay 1
key code kcode
end tell
end try
end if
end runExpose
on getkcode(fcode) -- for testing for Exposé keycode
set fcodes to {"F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", "F11", "F12", "F13", "F14", "F15"}
set kcodes to {122, 120, 99, 118, 96, 97, 98, 100, 101, 109, 103, 111, 105, 107, 113}
set kcode to missing value
if fcode is in fcodes then
set countfcodes to length of fcodes
repeat with i from 1 to countfcodes
if fcode is equal to item i of fcodes then
set kcode to item i of kcodes
exit repeat
end if
end repeat
end if
return kcode
end getkcode
on launchExpose()
set reqVers to 1050
set verCheck to my minOSVers(reqVers)
if verCheck = false then
else
try
delay 1
tell application id "com.apple.exposelauncher" to launch
delay 1
tell application id "com.apple.exposelauncher" to launch
end try
end if
end launchExpose
on minOSVers(reqVers) -- test for required OS version; reqVers is e.g. 1041 = 10.4.1
set numList to characters of (reqVers as string)
set decNum to 0
repeat with num in numList
set decNum to (16 * decNum) + num
end repeat
set sysv to (system attribute "sysv")
if sysv < decNum then return false
return true
end minOSVers
on testOthers() -- Don't run if Basilisk II or the GUI is running
tell application "System Events"
set myList to (name of every process)
end tell
if appName = "Basilisk II" then
if (myList contains "BasiliskII") is true then
set dialogText to "Shut down Basilisk II before running this installer."
errorQuit(dialogText, msgTitle)
end if
if (myList contains "BasiliskIIGUI") is true then
set dialogText to "Close Basilisk II GUI before running this installer."
errorQuit(dialogText, msgTitle)
end if
end if
if appName = "SheepShaver" then
if (myList contains "SheepShaver") is true then
set dialogText to "Shut down SheepShaver before running this installer."
errorQuit(dialogText)
end if
if (myList contains "SheepShaverPrefs") is true then
set dialogText to "Close SheepShaverPrefs before running this installer."
errorQuit(dialogText)
end if
end if
end testOthers
on errorQuit(dialogText, msgTitle) -- Fatal error, quitting script
tell me to activate
display dialog dialogText buttons {"OK"} default button 1 with icon stop with title msgTitle
error number -128
end errorQuit
on cancelQuit(dialogText, msgTitle) -- no error, just quitting script
tell me to activate
display dialog dialogText buttons {"OK"} default button 1 with title msgTitle
-- tell me to quit
error number -128
end cancelQuit