Action
Tag Type |
C++ code (built in to libHForm/scan_head.cc) |
Attributes |
[id=]string |
Required. A unique identifier string for this action.
(RPM/4.x only: The special string "always",
or no id at all in an Action section will cause it to
be processed every time the form is rendered. The
actual ID can be read {Exec} tags if the internal variable
_ASV_ is exported. To-do: put this in HFORM_ACTION_ID
environment variable instead.) |
default |
If present, this action will be executed whenever it is not
possible to determine which button the client pressed. |
onGet |
If present, this action will be executed the first time the client
requests the document. |
Contained Tags |
Set | Any sequence of these 6 tags is allowed |
Load |
Save |
Exec |
Cli |
Transmit |
Related Tags |
Submit or Apply
can be used in the Body section to link an
Action to a button on a form. In addition, some forms tags, like
Menu, Checkbox, and
Radio have an onChange= attribute which
automatically submits the form when a particular widget is
altered. Javascript is required for the onChange attributes to work. |
Examples |
|
The following example saves all variables in the public section
to a par file. The method=par attribute is redundant, because it
would have been assumed since the loc ends in ".par".
{Action id=apply}
{Save loc="test.par" method="par"}
{/Action}
The following example restores some default values (only to public
variables) from a par file.
{Action id=defaults}
{Load loc="defaults.par"}
{/Action}
This next example performs three steps:
- Save all public variables to a par file testh.par
- Invoke the handler, testh
- Reload the form with update values from testh_status.par
The "genh" method takes care of performing 1 and 2 in a single Save.
{Action id=apply}
{Save loc="testh.par" method="genh"}
{Load loc="testh_status.par"}
{/Action}
Here is an Action section which loads default values
that are built into the form itself:
{Action id="defaults"}
{Set name="loop" value="4"}
{Set name="speed" value="1000"}
{Set name="movespeed" value="4000"}
{Set name="homespeed" value="4000"}
{Set name="accel" value="10000"}
{Set name="decel" value="10000"}
{Set name="dxspline" value="50"}
{Set name="smooth" value="50"}
{Set name="nocircle" value="0"}
{/Action}
Finally here's an Action section which passes all form
variables as environment variables to a shell script
and then transmits the output of the shell script as
a file to the user. Before running the shell script,
the environment variable MODE is also set to "cut".
The content-type "application/x-galil" has been configured
to run a specific program on the data at the user's end.
{Action id="cut"}
{Set name="MODE" value="cut"}
{Save loc="ly2dmc_new.sh" method="xmit"}
{Transmit filename="%s.dmc"
content-type="application/x-galil"}
{/Action}