Scripting Example 66

; *****************************************************

; Example66.ftp

; =============

; This example demonstrates the new FORM functions

; interaction with your scripts. It displays a small

; calculator for calculating a Cubic. You provide the

; width, height and length and then click calculate.

; The form will display the result. You can also change

; the formula itself.

; Try it out by executing the script to see how this works.

;

; You can design your own interfaces in HTML and have

; that interface interact with your application

; written in the Perform Language.

; Examples 64 through 69 demonstrate the use of the

; various capabilities of FORMS and their interacation

; with your scripts.

;

; ---

;

; This demo accepts length, breadth and height of an object

; as well as the formula for calculation and when the

; user clicks the "Calulcate" link it will execute the

; "Calculate" subroutine below and display the result.

;

; Please view the source of the file called:

; pgCalculator.html

; located in the HTMLS folder.

; You will see that the "Names" of the input fields in that

; source have the same name as the variables:

; varHeight

; varLength

; varBreadth

; varResult

; varFormula

; in this script. This fact is the key to the interaction

; between your scripts and your HTML forms.

;

; NOTE: In the HTML source we "link" to a subroutine

; in this script by creating a HyperLink with a "gosub:"

; prefix. The hyperlink: gosub:Calculate executes the

; subroutine called "Calculate"

;

; -----------------------------------------------------------

; Commands demonstrated:

;

; OpenForm

; UpdateForm

;

; Syntax:

; OpenForm "<HTML Filename>"

; UpdateForm

;

; -----------------------------------------------------------

; NOTE: You are be able to execute this example unchanged.

; ***********************************************************

 

; -- Hide the window while accepting input from user

ToggleWindowOff

 

; -- Initialize the Page values

NumVariable varHeight

NumVariable varLength

NumVariable varBreadth

NumVariable varResult

Let varFormula="varHeight * varLength * varBreadth"

 

; -- Set the form properties like position and sizes

Let FormLeft=0

Let FormTop=0

Let FormWidth=550

Let FormHeight=460

Let FormCentered=True

 

; -- While hoevering over hyperlinks, display the link on the bottom

; of the window

Let FormDisplayLinks=True

 

; -- Now open the Form

OpenForm "%%PerformerDir%%\Htmls\pgCalculator.html"

 

EndScript

 

:Calculate

Let VarResult="%%varFormula%%"

UpdateForm

Return