home *** CD-ROM | disk | FTP | other *** search
-
-
- /*⌐ Copyright 1988 -- 1991 UserLand Software, Inc. All Rights Reserved.*/
-
-
- #include "appletinternal.h"
-
-
-
-
- boolean FrontierDoScript (bigstring script, bigstring returns) {
-
- /*
- Send a Do Script message to Frontier. The first parameter contains a short
- script to be run. The second parameter is the string that Frontier returned
- as the value generated by running the script.
-
- Returns true if we were able to send the message to Frontier, and Frontier
- was able to compile and run the script and Frontier replied with a returned
- value. FrontierDoScript returns false if Frontier isn't running, or if the
- script didn't compile or if there was a communications error.
-
- Frontier is not limited to running 255-character scripts or returning
- 255-character returned values. This routine can easily be enhanced to handle
- larger scripts and returned values.
-
- 11/6/91 DW: Set return string to "IAC Error" if we failed to create an Apple
- event descriptor or if the send failed. We're not suggesting that your
- error messages should be so brief, rather they should be custom-fit to the
- appropriate audience. Here, we want to show you how to locate errors relating
- to the IAC channel -- either you're low on memory, or the Apple Event Manager
- isn't present, or Frontier isn't running. Watch for this string in FDS's
- little window...
-
- 11/7/91 DW: This code was cribbed from the Frontier Do-Script program and adapted
- to run on top of the IAC Tools library. Use this version of FDS if you're using
- the IAC Tools library, use the original version if you're writing code to run
- directly on top of the Apple Event Manager.
- */
-
- register Boolean flhavereply = false;
- AppleEvent event, reply;
-
- copystring ("\pIAC Error.", returns); /*default return string*/
-
- if (!IACnewverb ('LAND', 'misc', 'dosc', &event))
- return (false);
-
- IACglobals.event = &event;
-
- if (!IACpushstringparam (script, '----'))
- return (false);
-
- if (!IACsendverb (&event, &reply))
- goto error;
-
- flhavereply = true;
-
- IACglobals.reply = &reply;
-
- if (IACiserrorreply (returns)) /*syntax error or runtime error*/
- goto error;
-
- IACglobals.event = &reply; /*get the string from the reply record*/
-
- if (!IACgetstringparam ('----', returns))
- goto error;
-
- AEDisposeDesc (&event);
-
- AEDisposeDesc (&reply);
-
- return (true);
-
- error:
-
- AEDisposeDesc (&event);
-
- if (flhavereply)
- AEDisposeDesc (&reply);
-
- return (false);
- } /*FrontierDoScript*/
-
-
-