AppleScripting SuperCard

This page was stimulated by a thread on the SuperCard Mailing list.
SuperCard has a small but powerful appleScript Dictionary.
As well as the required suite of open, print, run, and quit SuperCard only has 2 commands in its appleScript dictionary:
do string and evaluate
However these two commands will let you do anything you like to a SuperCard project or application from an appleScript.

do script string

This will let you run any command from an AppleScript.
A simple Example:
Open SuperCard and make a project.
Add this to the card script:
on testAppleScript
   put "message from appleScript"
end testAppleScript
open the appleScript Script Editor and type and run this script:
tell application "SuperCard 4.1.2"
	do script "testAppleScript"
end tell
switch to SC and you will find message from appleScript in the message box.
Create a button in your SuperCard project and give it this script:
on mouseUp
  answer "Message from appleScript"
end mouseUp
back in the appleScript Script Editor:
tell application "SuperCard 4.1.2"
	do script "send mouseUp to cd btn 1"
end tell
Obviously you can run a lot more complex script that these, but this should get you started.

evaluate string

This will cause SuperCard to evaluate string and return the value. eg:
tell application "SuperCard 4.1.2"
	evaluate "describe(this proj,wds)"
end tell
gives this:
"Wind	1	Big Test	100
Wind	2		101
Wind	3		102
Wind	4	myPalette	103"
We can write a custom function in SuperCard:
function testAs theString
   return "you said:"&&  thestring
end testAs
and pass it values from appleScript:
set quote to ASCII character 34
set x to "testAS(" & quote & "dance and skylark" & quote & ")"
tell application "SuperCard 4.1.2"
	evaluate x
end tell
This get round sending quotes to SuperCard in a crude way, I'd like to know a better one, but my appleScript knowledge is not extensive.

This of course returns "you said: dance and skylark" to AppleScript.

Back to the How To index

Valid HTML 4.01!