Implementing a batch file example
By way of example, consider a simple HTML input form constructed from a ".bat" file. This program generates an HTML form, and then displays the values filled in by the user when the submit button is clicked.
In addition to illustrating the mechanism for posting forms and getting values, this example further illustrates an important feature of the Sigma Framework, that is, the ability to directly program with such rudimentary tools as a Windows CMD.exe program.
Below is the example command file, residing in the "sigma-web/100_Form.cmd" directory. This program, by being located in the "sigma-web" directory and following the prescribed naming conventions, creates a tab at the top of the display called "Form". The ".bat" file is quite simple, and contains the following few lines:
REM: Filename: sigma-web\100_Form.cmd
Type \data\form.txt
Type %S_WIN32_POST%
The first line uses the "type" command to display the HTML for the form. That HTML resides in the file \data\form.txt, which is a small form with three input fields and a submit button as follows:
<form method=post
action=/s-cgi/web.exe?100_Form.cmd>
Arg1: <input name=arg1 value=""><br>
Arg2: <input name=arg2 value=""><br>
Arg3: <input name=arg3 value=""><br>
Submit data: <input type=submit>
</form>
When the user access the "Form" tab at the top of the display, a form with three input fields and a submit button is depicted. (The HTML is generated by the CMD "type", which is a standard Win32 command for displaying data to standard output.)
When the user clicks on the "Submit" button, the data is delivered directly to the S_WIN32_POST file as a series of input name and value pairs. Then, any contents of the %S_WIN32_POST% file are displayed to standard output. When the user clicks the submit button, the user sees the values that were posted to the form.
Although the above program is very simple, one can see how it could be made more powerful by replacing the second "Type" command with an external ".exe" program, which might input the data to a database, or append the data to a particular file, or generate specific HTML based upon the user input values. An even more obvious enhancement: the user could add a second "type" command that appends any posted data to a file, such as by adding the final command to the batch file as:
The above command would post any arguments to the "logfile.txt" file, possibly consisting of email addresses or contact information from a website.