I hope that this is the right section. I’m trying to make a launcher for the Commander Keen games in AppleScript. It works great in Script Editor:
set appLocation to path to me as string
set theCommanderKeenChoices to {"Episode One: Marooned on Mars", "Commander Keen in: Keen Dreams", "Episode IV: Secret of the Oracle", "Commander Keen in: Aliens Ate My Babysitter!"}
set theSelectedCommanderKeen to choose from list theCommanderKeenChoices with title "Commander Keen Collection" with prompt "Select your shareware game"
if theSelectedCommanderKeen contains "Episode One: Marooned on Mars" then
set theFile to appLocation & "Contents:Resources:games:keen123:Episode One - Marooned on Mars.app"
tell application "Finder" to open file theFile
else if theSelectedCommanderKeen contains "Commander Keen in: Keen Dreams" then
set theFile to appLocation & "Contents:Resources:games:keen3.5:Commander Keen in - Keen Dreams.app"
tell application "Finder" to open file theFile
else if theSelectedCommanderKeen contains "Episode IV: Secret of the Oracle" then
set theFile to appLocation & "Contents:Resources:games:keen45:Episode IV - Secret of the Oracle.app"
tell application "Finder" to open file theFile
else if theSelectedCommanderKeen contains "Commander Keen in: Aliens Ate My Babysitter!" then
set theFile to appLocation & "Contents:Resources:games:keen6:Commander Keen in - Aliens Ate My Babysitter!.app"
tell application "Finder" to open file theFile
end if
Here’s the app using the code above. This version uses the freely available Shareware/demo versions of the games.
The problem is when I try to use the same code in my Xcode version of the launcher. Once I try and open an app via the launcher, I get this message in the output box:
Can’t make «class ocid» id «data optr0000000000A5220000600000» into type constant. (error -1700)
This is the code that ends up working in Xcode:
on buttonPushedKeen1_(sender)
set theFile to "Macintosh HD:Applications:Commander Keen Collection:Commander Keen Collection.app:Contents:Resources:files:games:keen123:Episode One - Marooned on Mars.app"
tell application "Finder" to open file theFile
return
end buttonPushedKeen1_
Is there any way I can fix the type error so that I can use the original code?