Click the links below to explore the different sections of our site. If you have any questions about our products or services, don't hesitate to contact us.
Following are a number of links to pages that might interest you as a visitor of this web site.
copyright © 2005-07 by Mark Schonewille & Economy-x-Talk

Economy-x-Talk - Sample Scripts

Answer and Ask with AS (nice)

Here's a solution for using AppleScript dialogs inside HyperCard and
retrieving the results of the user's action.

There are three sets of scripts. The first one is an AppleScript Ask
dialog. The second one is an AppleScript Answer dialog with two buttons.
The third is an AppleScript Answer dialog with three buttons.

To use these, place the AppleScript handlers in a stack-in-use, or in a
card, background or stack script of the current stack. Use the HyperTalk
scripts in buttons to call them.

You'll notice that in the 3-button Answer dialog, I had AppleScript
return "button returned of result". This delivers just the button name,
without quotes or braces.


Supporting Function:

The string returned from AppleScript when you ask for "text of result"
looks like...

  {"Text","ButtonName"}

so to make that usable, you can use this function:

function getASresult theText
  delete char 1 of¬
  theText -- "{"
  return value of¬
  word 1 of theText
end getASresult


Paul Foraker





--AppleScript Ask dialog
on ASAsk(str, defltText)
  tell application "HyperCard"
    try
      display dialog str default answer defltText with icon 1
    on error
      return ""
    end try
  end tell
 text of result
end ASAsk

--AppleScript Answer Dialog with Two Buttons
on ASTwoBtnAnswer(str, btnOne, btnTwo, deflt, theIcon)
  tell application "HyperCard"
    try
      display dialog str as text buttons {btnOne, btnTwo} ¬
        with icon theIcon default button deflt
    on error
      return ""
    end try
  end tell
 text of result
end ASTwoBtnAnswer

--AppleScript Answer Dialog with Three Buttons
on ASThreeBtnAnswer(str, btnOne, btnTwo, btnThree, deflt, theIcon)
  tell application "HyperCard"
    activate
    try
      display dialog str as text buttons {btnOne, btnTwo, btnThree} ¬
        with icon theIcon default button deflt
    on error
      return ""
    end try
  end tell
  button returned of result
end ASThreeBtnAnswer

on run()
  set rslt to item 1 of ASAsk("Enter a text...","This is a text") as text
  ASThreeBtnAnswer(rslt,"Cancel","Yes","No","Cancel",0)
end run





Keep this extensive resource of tutorials and samples on-line! Support RunRev.info!
Yes, this script is useful. I make a donation and choose freely how much I want to donate on-line (PayPal). Click here if you want to make a donation in dollars.This script has not (completely) solved my problem and I want Economy-x-Talk to take care of it. Let me contact you.
Copyright©2002-2008 by Mark Schonewille, Nijmegen, the Netherlands. This web site is in no way affiliated with Runtime Revolution Ltd., but we do recommend the Revolution development platform.