Modular Software - Home PicLan-IP - Home

Introduction to mv/WEB

Part 2 - MultiPage Applications with Persistence

Now that the basic concepts of program flow and using HTML FORM input tags has been covered, it is time to make this sample application more functional. The next iteration of this example will: This is a main-line source code for the core application in mv/BASIC:
_PROGRAM APP.FILE APP2
_PVAR ID
_PVAR D
_FILE CUSTFILE CUST.FILE
LOOP WHILE 1 DO
   ID = ''
   _PAGE HOST C:/WWW/APP/APP2_P1.HTM
   IF EXIT THEN
      _PAGE HOST C:/WWW/APP/INDEX.HTM
   END
   READ D FROM CUST.FILE , ID THEN
      _PAGE HOST C:/WWW/APP/APP2_P2.HTM
      IF SUBMIT THEN
         WRITE D ON CUST.FILE , ID
      END
   END
REPEAT
Here is what the application does:
_PROGRAM APP.FILE APP2
This line defines where the PLZ program will generate the executable web application. In this case, the application will be stored in the MV file APP.FILE with a base page name of APP2.HTM.
 
_PVAR ...
These lines define persistent variables. A persistent variable will be preserved by the mv/WEB environment across _PAGE calls. The variables ID and D are defined as persistent. ID will contain the item-id of the record being edited. D is a dynamic array that will contain the actual data.
 
_FILE CUSTFILE CUST.FILE
The statement will cause the mv/WEB application to automatically open the datafile CUSTFILE to the file variable CUST.FILE. The application can then use the CUST.FILE variable to reference this data file.
 
LOOP ...
This is the main outside loop. In this example, this program will run forever, or until exited. The user can exit by either going to another web URL, or by pressing the EXIT button which will pass control to INDEX.HTM which is defined as a dead-end page.
 
ID = ...
The first page will input the value of the variable ID. Your application code must supply an initial value. In this case, the initial value is null.
 
_PAGE HOST C:/WWW/APP/APP2_P1.HTM
The first page to be called enters the item-id of the customer record to edit. There are two submit button, one to continue, and one to branch to INDEX.HTM.
 
IF EXIT THEN ...
If the EXIT submit button is pressed, then the mv/BASIC variable EXIT will be set to 1. In this case, the application will chain to the page INDEX.HTM, which is a dead-end page without an HTML form.
 
READ D FROM CUST.FILE , ID THEN
The existing customer record is read from the just opened CUSTFILE data file. If the selected record is found, it's data will be read into the variable D.
 
_PAGE HOST C:/WWW/APP/APP2_P2.HTM
This page will actually display and allow editing of the attributes in the dynamic array variable D.
 
IF SUBMIT THEN
If the user submits the APP2_P2.HTM page by pressing the submit button, then the application program will actually perform the data update with a standard WRITE operation.
 
WRITE D ON CUST.FILE , ID
The edited record can then be written to the live customer file.
 
REPEAT
The program then loops to the top to process another record.
This application calls two main HTML input pages, one to input an item-id, and one to edit a data record. In performing this processing two persistent variables and one file variable are defined.

This is the HTML source code for the first web page:
<html>
<head>
  <title>mv/WEB Demo Application</title>
</head>
<body>
  <form>
    <pre>
Enter ID: <input type="text" size="20" name="ID"></pre>
    <p>
      <input type="submit" name="SUBMIT" value="Submit">
      <input type="submit" name="EXIT" value="Exit">
    </p>
  </form>
</body>
</html>
When the browser runs the demo application, this is what the user will see:
Enter ID: 
 
This is the HTML source code for the send web page:
<html>
<head>
  <title>mv/WEB Demo Application</title>
</head>
<body>
  <form>
    <pre>
Edit customer |ID|</pre>
    <pre>
Name:   <input type="text" size="40" name="D&lt;1&gt;">
Address:<input type="text" size="40" name="D&lt;2&gt;">
City:   <input type="text" size="30" name="D&lt;3&gt;">
State:  <input type="text" size="2" name="D&lt;4&gt;">
Zip:    <input type="text" size="10" name="D&lt;5&gt;"></pre>
    <p>
      <input type="submit" name="6" value="Submit">
      <input type="submit" name="7" value="Exit">
    </p>
  </form>
</body>
</html>
When the browser runs the demo application, this is what the user will see:
Edit customer |ID|
Name:   
Address:
City:   
State:  
Zip:    
 
You have just written a fully functional data entry HTML applicaton with two HTML pages and 17 lines of mv/BASIC source code. Of course there is a lot that can be added to this example to create a more complete application including:

Continue to Part 3

Modular Software - Home PicLan-IP - Home
© Copyright 1996-1998  Modular Software Corporation.All rights Reserved.