The mv/WEB processor is a program that is used to convert a top-down MultiValue web application program into a series of event driven web "pages" that are processed by the PicLan-IP Coyote Web Server. This allows MultiValue applications developers to more easily and quickly develop and deploy web applications without having to deal with the low-level intracasies of event processing and persistence.
Additional documentation:
The underlying problem is one of "persistence". Persistence is the description of the necessity for the software running on the web server to remember where it is during the execution of a multi-page web application. Most application programs take persistence for granted. Because a standard MultiValue terminal application runs top-down, persistence is simply the state of the programs variables and the programs current execution location as the program runs. Web applications do not work like this. The only mechanism for persistence with a web application is to let the web browser store data variables that are maintained from page to page (either in HTML form "hidden input fields" or in browser "cookies"). This environment can make implementing multi-page applications confusing unless an adequate toolkit is available to ease the task of implementing application persistence.
The general principal of mv/WEB is that your application can write any standard mv/BASIC code except PRINT and INPUT statements (you can actually use PRINT statements for debugging, but the web user will not see this). Instead of PRINT statements, you build dynamic web pages to display to the user. Instead of INPUT statements, the user can fill in HTML form statements on the web pages that you build. The result is an environment that seamlessly integrates page at a time HTML form processing with top-down mv/BASIC applications.
Your application consists of a number of seperate text documents. The core document is an mv/BASIC source code item that contains standard mv/BASIC source code, extension mv/WEB "statements", and calls to invoke some number of HTML formatted web pages. This core document is stored as a standard item in a MultiValue data file (or in a HOST or DSG accesssible file) in the same manner as an mv/BASIC source code item is stored. The core source item does not actually contain the HTML documents that the user will see and interact with. These documents are stored in other MultiValue items (or in HOST or DSG accessible files) and are referenced by the core application source code. This allows you to write the mv/BASIC source code using standard source editor tools (like the Pick line editor) while using graphical HTML authoring tools (like Front Page or Hot Metal Pro) to design HTML display and entry pages.About storing source code
The mv/WEB processor takes as source documents both mv/BASIC source code and HTML source code. Both of these document types are simple text documents. In order to allow for maximum flexibility in where these documents are stores, you actually have three choices of where mv/WEB can read source documents from:
- As items in a standard MV or Pick format data file.
- As text files in an underlying host accessible file system.
This allows hosted PicLan-IP host systems like D3, Universe, and mvBase the convenience of storing source code in NT or Unix directories instead of requiring that they be explicitly imported into Pick.
- As text files in a PicLan DOS Services Gateway accessible file system.
This allows native PicLan-IP host systems like AP/Pro, Mentor PRO, and Sequoia PRO the convenience of storing source code in network directories instead of requiring that they be explicitly imported into Pick.
When you define a text input form field, you use the name of an mv/BASIC variable or dynamic array reference as the name of the form field. Examples of this in HTML source format would be:
<input type="text" size="30" name="D">
<input type="text" size="30" name="X<12,4>">The first example will setup an input field that edits the mv/BASIC varaible 'D'. The second example edits the mv/BASIC dynamic array reference 'X<12,4>'. Note that the raw HTML code will "quote" delimiter character like '<' and '>' (into < and >). If you use an HTML editor like Front Page to create your HTML documents, you should be able to type variable names in the 'X<12,4>' format and the HTML editor should quote this for you.
The behavior of text input boxes is that the value of the specified variable or dynamic array reference will be used as the initial value for the text input field when the HTML page is displayed. The user can then edit this value and the new value will be stored into the same mv/BASIC variable or dynamic array location when the form is submitted back to the server.
Text input boxes support several "options" that control formatting. You can use text input fields such as:
<input type="text" size="30" name="D" conv="D4/">This statement will apply an OCONV(D,'D4/') conversion to the data before it is presented to the user and an ICONV(D,'D4/') to the data that the user types in before it is presented back to your mv/BASIC application code. You typically use these functions for handling dates and money input fields.
You can also specify iconv="..." and oconv="..." seperately to allow for different conversion strings for input and output operations. You cannot use the iconv/oconv and conv syntaxes with the same input field.
<textarea name="X<12>" ...> </textarea>If the mv/BASIC variable specified in name is a simple variable, then the textarea box will manipulate a multi-attribute Pick variable with one attribute per line. If the mv/BASIC variable specifies an attribute extraction, then multiple values will be manipulated. If the mv/BASIC variable specifies a value extraction, then multiple sub-values will be manipulated.
Conversion operators are not supported on TextArea controls.
<select name="X Y" ...> </select>The first variable name contains a list of text lines that are used to populate the select control. This list can be multi-attribute, multi-value, or multi-sub-value depending on whether a simple variable or dynamic array expansion is specified.
The second variable contains a related set of multiple attribute, value, or sub-value entries that are used to specify which select elements are selected. This arrays contains integer numbers that relate to the first variables elements. An example of building these elements would be:
X<1> = 'Line 1' X<2> = 'Line 2' X<3> = 'Line 3' Y<1> = 1 Y<2> = 3The page is then called with a select control:
<select name="X Y" MULTIPLE> </select>When this page is called, "Line 1" and "Line 3" will start highlighted. After the page is submitted, the variable Y will contain a multi-attribute dynamic array of the indexes of the lines that are highlighted. The variable X will not be modified by this operation.
When you define a checkbox input form field, you use the name of an mv/BASIC variable or dynamic array reference as the name of the form field. Examples of this in HTML source format would be:
<input type="checkbox" name="D">
<input type="checkbox" name="X<12,5>">The first example will setup an input field that is based on the mv/BASIC varaible 'D'. If the value of the variable 'D' evaluates to "true" then the checkbox will start checked. Otherwise, the checkbox will have an initial state of cleared. After the user submits the data entry screen, the variable will have the value of '0' or '1' depending on whether the checkbox is clear or checked. You can also use dynamic array references to refer to checkbox input fields.
When you define a group of radio buttons, you use the name of an mv/BASIC variable or dynamic array reference as the name of the form field. You setup a "value" that is the value associated with a particular button. To create a grouping of associated buttons, you assign the same mv/BASIC variable name or dynamic array reference to each button in the group. Examples of this in HTML source format would be:
<input type="radio" name="D<40>" value="0"> 0-users <br> <input type="radio" name="D<40>" value="8"> 8-users <br> <input type="radio" name="D<40>" value="16"> 16-users <br>This example will assign the mv/BASIC dynamic array reference the values of 0, 8, or 16 depending on which button is checked. The initial value for the button will depend on the starting contents of 'D<40>'. If the starting contents are 0, 8, or 16, then the appropriate button will be checked. If the starting contents are otherwise, then no button will be checked.
"submit" buttons
Your HTML form can have any number of "submit" buttons that allow the users to perform various tasks. Each of these submit button has a unique mv/BASIC variable name or dynamic array reference associated with it. If the user presses one of these buttons, your application code will resume control with the variable or dynamic array reference associated with the pressed button set to '1'. Variables or dynamic array references for other button that were not pressed are set to '0'. This allows you application code to easily test to see which button was pressed.An example of the HTML source for a "submit" button is:
This example will set the mv/BASIC variable 'CONT' to '1' if the user presses the button labeled "Continue".<input type="submit" name="CONT" value="Continue">"clickable" images
Your HTML form can also have any number of clickable images. These behave exactly the same way as submit buttons, but because they are graphics elements, they give you more flexibility in page appearance. Again, each image should have a unique mv/BASIC variable name or dyanmic array reference associated with it.An example of a clickable image in HTML source would be:
This example will set the mv/BASIC variable 'BACK" to '1' if the user clicks on the image LEFT.GIF.<input type="image" name="BACK" src="IMAGES/LEFT.GIF" alt="Back" align="bottom" border="0" width="32" height="32">
Creating HTML Form Fields that mv/Web Ignores
If you create an HTML form field with a name that begins with an underscore, the mv/Web generator will remove the underscore but otherwise ignore the tag passing it through to the output page. This allows you to create input fields that are your responsibility to maintain with a minimum of syntax.Naming HTML Form Fields
If you are writing client-side JavaScript code, the mv/Web generator will name HTML form fields as integer number (1, 2, 3, etc.). mv/Web uses these short names to minimize network transmission size so that your web applications runs with maximum efficiency. Unfortunately, this can make referencing these fields from JavaScript functions somewhat inconvenient.To help you with JavaScript coding, you can override the default behaviour of mv/Web and specify your own field names with the following syntax:
The mv/Web generator will use VAR1 as the mv/BASIC variable name to manipulate and call the field FName when generating the page. This allows your JavaScript code to reference FName when referring to this HTML form field.<input type="text" name="VAR1 FName" ...>All mv/Web supported HTML form fields include this support:
The clickable image control can have two equivelent syntaxes:<input type="checkbox" name="VAR FName" ...> <input type="submit" name="VAR FName" ...> <input type="text" name="VAR FName" ...> <input type="password" name="VAR FName" ...> <input type="textarea" name="VAR FName" ...>These two syntaxes will generate the same HTML page.<input type="image" name="VAR" alt="FName" ...> or <input type="image" name="VAR FName" ...>Select boxes use the syntax:
Radio buttons are supported with the syntax:<select name="VAR1 VAR2 FName" ...></select>You are required to insure that all radio buttons in the group use the same VAR FName coding so that the group is maintained as a group.<input type="radio" name="VAR Fname" ...>
For detailed documentation on mv/WEB Basic Syntax elements:
Defining a module as a main-line PROGRAM or SUBROUTINE
The first line of your application source code item should be:or_PROGRAM destfile destnameThe PicLan-IP Web Application Generator will store the resulting web application in a MultiValue data file. You must specify a file and item-id to store the destination application. When a main-line _PROGRAM is defined, the application URL page will get the name that you specify in the _PROGRAM statement with .HTM appended to the end. If you are defining a _SUBROUTINE module, this code is not directly referenceable from the web but must be _CALLed from an _PROGRAM application. Subroutines may have a parameter list to pass data to and from subroutines._SUBROUTINE destfile destname {parameter{,parameter...}}Defining variables
When you write your core application, you will first need to define three types of mv/BASIC variables:In addition, you can use any number of temporary mv/BASIC variables without defining them. These variables will be purely local to your mv/BASIC core application program and will reset to "unassigned" whenever an HTML page is called. You can use either local application variables or defined persistent variables to pass data to HTML pages.
- "Persistent" variables
- "Common" variables
- "File" variables for open MultiValue data files
Persistent variables
A persistent variable is a variable that will maintain it's value for the life of the application's execution. You use persistent variables for all storage elements that need to exist across HTML page calls. You can store any legal MultiValue string element in persistent variables including dynamic arrays. You cannot declare the following elements as persistent variables:If you declare a persistent variable in a _SUBROUTINE module, these variable values will be initialized to a null string whenever the subroutine is called.
- Dimensioned arrays
- File variables
- Select variables
You should also try to keep the number of persistent variables to a "reasonable" level. The PicLan-IP Web Application Generator saves the contents of persistent variables by storing them in a workfile (WWW.CTRL,APP.STATES) when every HTML page is called. The larger the persistent variables size is, the more overhead there will be on the Pick host. If your persistent variables are less than 10K in total string size, this should not be a concern to you.
Persistent variables are defined by entering the following line at the top of the core source code document:
You can define multiple mv/BASIC variables on a single line or you can use multiple _PVAR lines within a single application._PVAR variable{,variable}Common variables
A common variable is a special-case persistent variable that is shared between main-line and subroutine modules in the same way as COMMON is declares in a standard mv/BASIC application.Common variables are defined by entering the following line at the top of the core source code document:
You can define multiple mv/BASIC variables on a single line or you can use multiple _CVAR lines within a single application. If you use common variables to pass data between main-line programs and subroutines, it is your responsibility to insure that the number of variables and order of variables defined in common matches._CVAR variable{,variable}Local variables
Local variables are no longer defined as of version 2.0.0.115. This means that you should remove _LVAR statements from any existing PicLan-IP web application modules. One behavior difference that may impact existing programs is how local variables were initialized. In older releases, _LVAR variables would be initialized to null strings. With 2.0.0.115, local variables will start out as "unassigned" and you need to explicitly set their values or else the run-time web server will abort on a "unassigned, zero used" error.File variables
You have two choices of how to allocate file variables within your core application module.You can manually open MultiValue files with the OPEN statement each time that you need to access the file. Remember that the file variable will be erased whenever you call an HTML page, so you will have to re-open your data files after each HTML page is called.
You can let the PicLan-IP Web Application Generate open data files for you by using the _FILE tag:
This will cause the generated programs to automatically open the specified file each time the core application is entered._FILE variable file_nameThe _FILE command is intended as a convenience. It is actually much less efficient that manually opening files as they are needed because the files will be opened every time that a page is submitted even though you may not need to use the files every time.
You can specify multiple _FILE lines to open multiple files.
Calling HTML Pages
You invoke HTML pages by including a _PAGE line in your source document:The three formats of the _PAGE command allow you to store your HTML documents either in MultiValue data files, or in host directories accessible either through host file access calls (for Unix and NT host) or PicLan DSG calls (for native hosts)._PAGE FILE file_name item_name _PAGE HOST host_path _PAGE DSG dsg_name dsg_pathWhat happens when you call a page
When you call an HTML page, any insertion points that you have in the page will be resolved. This allows you to build mv/BASIC variables that will then be merged with |...| merge points in the page. You should define these varaibles as either persistent or local variables so that they will be passed successfully to the called page.Next, any HTML form input fields are setup with their initial values based on the values in their corresponding mv/BASIC variables or dyanamic array references. The page is then transmitted to the user.
After the user processes the page and selects a submit button or clickable image, control is returned to the application. The first step that occurs is that all of the HTML form input fields in the application are read into their corresponding mv/BASIC variables or dynamic array references. Once the input fields have been read, control is passed back to your application code.
Deciding what to do after a page returns
After an HTML page has been called, if the user clicks on a submit button or clickable image, control will return to your application. You can test for which button or image a user clicked on by simply testing the associated variable or dynamic array reference for the value of '1':You can also access the contents of HTML input text boxes, check boxes, and radio button by simply accessing the associated value of the mv/BASIC variable or dynamic array reference.BEGIN CASE CASE BACK ... the user hit the back button CASE CONT ... the user hit the continue button END CASECalling Web Subroutines
You can call other web application subroutines that are stored in the same application code file by using the _CALL statements as in:The subname is the name of the subroutine to call. With build 2.0.0.116, you now must enclose this subroutine name within quotes. You can also set the value of a variable to the subroutine name._CALL "subname" {parameter{,parameter...}} _CALL variable {parameter{,parameter...}}Parameters may be either variables or dynamic array references, which pass bi-directionally, or constants or calculations which are passed to the subroutine but do not pass back. If the specified string contains a quote character or an operator (like :, +, etc.) then the string is assumed to be a one-way parameter.
Calling Local Subroutines
It is permissible to call local subroutines with:This is a new feature of build 2.0.0.116._GOSUB labelReturning from Subroutines
An external or local subroutine returns control to the calling application with the _RETURN statement:This statement has no parameters and must be placed on a line by itself._RETURN
This command will create the following additional items in the same file as the core module:PLZ FILE filename appname (options) PLZ HOST path (options) PLZ DSG dsgname path (options)
PLZ options include:
This example assumes that you are generating application into a MultiValue file named APP.FILE. It is perfectly acceptable to generate multiple applications into a single MultiValue data file.HTTP DIR=*:80 /APP/ FILE APP.FILE
In order for images to be imported correctly, you must be sure to use relative link addresses to images.
While the application is running, all submit requests will use a action type of "POST" and the actual displayed URL will not change (the post operations always post back to the same URL). This prevents the user from bookmarking the application part of the way through.http://www.domainname.com/app/custquery.htm