Extending Tango FunctionalityScript and External ActionsThe Script action provides an interface within Tango for executing JavaScript code at the server. The script executed can return to Tango a value you can access using Results HTML. The External action calls an executable invoked using a command line, a Dynamic Link Library (DLL), or a Java class file to perform processing and, if desired, return results. Under Mac OS, the External action can also send a specified Apple Event with parameters to a specified application and retrieve the results, or use Apple Event actions to communicate with applications you write in AppleScript. This chapter covers the following topics:
![]() Executing JavaScriptThe Script action provides an interface for executing core JavaScript code at the server. The script executed can return a value to Tango, which is accessible using Results HTML. Tango is JavaScript 1.2 compatible, meaning it includes the official JavaScript Reference implementation from Netscape, and conforms to version 1.2 of the language.
Setting Up a Script Action |
|
![]() |
When you drag the Script action icon from the Actions bar into an
application file, the Script action editing window appears.
The JavaScript object and variable scope parameter defines the lifetime of the objects and functions declared in the script. This is a concept similar to the scope of variables in Tango. The drop-down menu has two choices: |
For information on using the script text area, see "HTML Editing Window", and "The SQL Query Window". |
You enter the text script to be executed in the JavaScript script text area. The script may contain meta tags. All meta tags in the script are substituted before the script is executed. The script text area functions the same as HTML text editing windows. When you right click the script text area, the same context sensitive menu for the SQL text area of a Direct DBMS action appears. Executing a Script ActionTango Server executes the Script action in a similar way it executes the <@SCRIPT> meta tag. |
For more information, see "<@SCRIPT> in the Meta Tags and Configuration Variables manual. |
Any value returned by a script is accessible in the Results HTML by using <@COL 1> inside a <@ROWS> block. The action's result set (a 1 x 1 array) is also stored automatically in a local variable, resultSet. ![]() Using an External ActionSetting Up an External Action |
![]() |
When you drag the External action icon from the Actions bar into a
file, the External action editing window automatically opens.
The standard External action type is based on the current platform, in this case, DLL. You can also specify Java, command line execution or Apple Event. From the Type drop-down list, select the type of action you want to execute.
|
See the Tango Enterprise User's Guide (Mac OS) for a description of the Apple Event External action. |
This User's Guide gives a description of each type of External action. The DLL, Command Line and Java externals are available if you plan to deploy your application file on Windows. Command Line and Java are available for Unix, and an Apple Event action can only be used with the Mac OS version of Tango Server. Configuring a DLL CallTo configure a DLL call
|
Using a Command LineExternal actions allow you to run any executable file (for example, batch file, shell or Perl script, C application) and, if desired, retrieve results. Values are passed from Tango to the executable by means of environment variables. Results are retrieved by Tango from text that the external action has written to the standard output stream (stdout). Rows and columns are delimited with tabs and returns, respectively. To configure a command line External action
|
|
Environment variables may include any value-returning Tango meta tags, which are substituted when the action is executed.
|
|
Appendix C provides additional information on calling Java classes from Tango. |
Configuring a Java ActionTango ships with its own Java server. The Java server is on the same machine as Tango Server. The Java type external action allows you to connect to the Java server. To configure a Java external action
|
Arguments may include any value-returning Tango meta tags, which are substituted when the action is executed. Configuring an Apple Event (Mac OS only)To configure an Apple Event external actionTo use External actions you should be familiar with Apple Events and know the event and parameter codes of applications with which you want to communicate. You can also use Apple Event actions to communicate with applications you write in AppleScript. From the Type drop-down list, select Apple Event. The External action editing window for the Apple Event type appears. The Apple Event dialog box has the following components:
To add a parameter to the list, do either of the following:
A blank row appears in the Parameters area. The parameter values can be entered as fixed values, or you can use any Tango meta tags that return values. Tango can send only text parameters and accepts only a string (or value that can be converted to a string), list of strings, or list of lists of strings as return values. If you need to communicate with applications requiring non-string parameters or that return results in a format Tango cannot handle, you should use an intermediate AppleScript application. Calling AppleScript Applications |
|
For more information on Apple Events and AppleScripts, consult your Macintosh documentation. |
AppleScript application handlers that are to be called from Tango require special subroutine names and parameter labels. Here is an example: on «event TNGOTest»
dir_param given «class arg1»:arg_1, «class arg2»:arg_2
return {col_one, col_two, col_three} The first four letters of the AppleScript handler name (after the event keyword) make up the Event Class Code; the second four are the Event Code. In this example, the event class is TNGO and the event is Test. Except for the direct parameter, which immediately follows the handler name, the parameters must be labeled with the class keyword and a unique four letter code. In this example there are three parameters: the direct parameter, "arg1", and "arg2". As with any other applications Tango communicates with through Apple Events, results from an AppleScript application must be returned as a string, list of strings, or list of lists of strings. Here is an example of each:
Assigning AttributesYou can also assign the following attributes to an External action: |
For a description of each attribute, see "Assigning Attributes to Actions" . |
You assign these attributes using the Attributes menu. You can also right click the External action icon or name in the application file, or click the open External action editing window to display a context-sensitive menu of available attributes. The Properties command is also available in this menu. If you right click an action parameter, the Edit command is active allowing you to edit the parameter value; otherwise, it is disabled (grayed). Deleting ParametersTo delete an External action parameter |
You can also right click the parameter, and choose Delete from the context-sensitive menu that appears. |
|
Executing an External ActionWhen Tango Server executes an External action, the DLL, command line, Apple Event, or Java specified is called and the parameters specified are passed to it. Any data returned is accessible with <@COL> tags in a <@ROWS></@ROWS> block in the action's Results HTML. For example, if a row set with three columns is returned, all the results can be returned with the following Results HTML: <@ROWS>
For DLLs, rows and columns are determined by the interface defined in Appendix B. For the command line and Java options, the value returned is treated as tab and return delimited: a tab separates columns and a return separates rows. Only textual data can be returned from an External action. The entire result rowset from an External action is automatically assigned to a local array variable, resultSet. If the External action generates no data, and you have specified No Results HTML for the action, that HTML is processed instead of the Results HTML. ![]() Disabling JavaScript, Java and External Actions |
|
JavaScript, Java, and External actions are by default enabled in Tango. If you want to disable (or enable) these features, you can do so by changing the following options in the config.taf application file, in the Feature Switches screen: |
|
Copyright © 1998, Pervasive Software Inc. All rights reserved.