next up previous contents index
Next: Example Script Up: HTML Forms and Scripts Previous: Introduction to HTML Forms   Contents   Index

Interfacing Forms to Xic Scripts

If a form has an action which is in the format ``action_local_xic scriptname'' then, when the submit button is pressed, the script in scriptname will be called, with the following:

Within the script, one must supply the following logic:

Below are the first few lines of an example script which could interface to the example form given above. When the script is selected in the User Menu, it will display the help window containing its input form. When the submit button of the form is pressed, the script will be called again, and the data processed.

#ifndef SUBMIT
# SUBMIT is not defined, so we are being called from the User Menu
# pop-up our input form in the HTML viewer and exit
TextCmd("help spform.html")
Exit()
#endif

# We are being called from the form (SUBMIT is defined)
# First check the option menu return.  The entries are digits, which must
# be converted from text strings to real values
#
if Defined(opmenu)
    num = ToReal(opmenu)
else
# This should never fail, since the option menu always has a selection
    ShowPrompt("number of turns unknown")
    Exit()
end

# Next check the return from a text entry object.  Exit if the variable
# is undefined (text input empty), or the result is a bad numeric value
#
if Defined(pwidth)
    width = ToReal(pwidth)
    if (width < 0)
        ShowPrompt("Bad input (< 0) for width: ", width)
        Exit()
    end
 
    ShowPrompt("width unknown")
    Exit()
end

(check other input variables)
(perform calculations/operations)
Exit

This is typical boilerplate for a form-entry script.


next up previous contents index
Next: Example Script Up: HTML Forms and Scripts Previous: Introduction to HTML Forms   Contents   Index
Stephen R. Whiteley 2017-03-22