Here is a very basic example of how to send parameters from an HTML form (on a server) to a Focus program (in my environment, Focus 7.02 resides on an MVS mainframe). The example below shows how to display the output of an existing Focus program in whatever output format the user selects (limited to a list of options that you provide on the HTML form).
First, the Focus program (residing on the mainframe) - using the Car file:
-SET &OUT = IF &FRMT EQ 'DOC' THEN
- 'ON TABLE PCHOLD FORMAT DOC' ELSE
- IF &FRMT EQ 'EXL2K' THEN
- 'ON TABLE PCHOLD FORMAT EXL2K'
- ELSE ' ';
TABLE FILE CAR
PRINT CAR COUNTRY
WHERE RECORDLIMIT EQ 10
&OUT
END
-* end of program
&FRMT is passed to the above program from the HTML form (see below). &OUT is a simple amper variable that contains the ON TABLE PCHOLD FORMAT 'formattype' program text that will be substituted into the Table File request at the time of execution.
The HTML file looks like this:
<HTML>
<body>
<form action="
method="GET">
<input type="hidden" name="IBIF_ex" value="CARTEST">
<center><h2><font face="Arial">Car Test</font></h2></center>
<center>
<table>
<tr>
<td><font size="2" face="Arial"><b>
Select report output option:</b></font></td>
<td><font size="2" face="Arial">
<select name="FRMT">
<option selected value="BROWSER">
Browser format</option>
<option value="DOC">Text Document</option>
<option value="EXL2K">Excel2000</option>
</select>
</font>
</td>
</tr>
</table>
<p>
<font face="Arial">
<input type="submit" name="Submit" value="Run Report">
<input type=reset name="reset" value="Reset Values">
</font></p>
</form>
<center>
</body>
</HTML>
In this form, the following lines are important:
1. <input type="hidden" name="IBIF_ex" value="CARTEST">
"CARTEST" is the name of the Focus program (Uppercase - case sensitive).
2. <select name="FRMT">...</select>
This HTML phrase gives a name to the variable that is passed to the Focus program (with an ampersand added).
3. <option selected value="BROWSER">Browser format</option>
<option value="DOC">Text Document</option>
<option value="EXL2K">Excel2000</option>
These are the options that the user sees and can select. The default value is prefixed with 'selected', as in the first option. The 'value' associated with the selected option is passed as the value of FRMT back to the Focus program.
When the user clicks the Submit button on the form, a URL is created that contains the Focus program name and the form variables. These values are passed to the server (named in the 'FORM ACTION=' HTML ocde) and then on to Focus.
The mainframe CARTEST program is executed. The value of FRMT that was passed from the form is substituted into the Focus program and the -SET logic creates a PCHOLD statement on the fly. The Table File request is executed and the output is delivered according to how the PCHOLD statement is created.
Hope this helps.