_PROGRAM APP.FILE APP2_PVAR ID _PVAR D_FILE CUSTFILE CUST.FILELOOP WHILE 1 DOID = ''_PAGE HOST C:/WWW/APP/APP2_P1.HTMIF EXIT THEN _PAGE HOST C:/WWW/APP/INDEX.HTM ENDREAD D FROM CUST.FILE , ID THEN_PAGE HOST C:/WWW/APP/APP2_P2.HTMIF SUBMIT THEN WRITE D ON CUST.FILE , ID ENDENDREPEAT |
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.
- _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 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> |
|
<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<1>"> Address:<input type="text" size="40" name="D<2>"> City: <input type="text" size="30" name="D<3>"> State: <input type="text" size="2" name="D<4>"> Zip: <input type="text" size="10" name="D<5>"></pre> <p> <input type="submit" name="6" value="Submit"> <input type="submit" name="7" value="Exit"> </p> </form> </body> </html> |