001 _PROGRAM APP.FILE CLOOKUP
This line defines the applications location and name. APP.FILE
is a MultiValue data file that will be used to store the resulting web
application when it is generated. CLOOKUP.HTM will
be the name of the application.
002 *
003 * Sample multi-page web application
004 *
005 *
006 *
007 _PVAR CUST
This line defines an mv/BASIC variable that will be "persistent".
In the interest of performance, not all variables are preserved across
page executions. You can define up to 490 variables as persistent
or local. Persistent variables may contain numbers, strings, or dynamic
arrays.
008 _FILE FILE.VAR CUST.FILE
This defines a file variable FILE.VAR that
will refer to the MultiValue data file CUST.FILE. Because
of the nature of the web, there are limitations to persistent non-string
variables such as file variables and select variables. This shorthand
allows you to define a mv/BASIC variable that will access a MultiValue
data file using standard READ/WRITE mv/BASIC syntax.
009 *
010 CUST.ID = ''
When using HTML forms to input data, you must initialize the
variables to avoid "unassigned variable, zero used" run-time errors.
011 _PAGE HOST O:/WWW/APP/CUSTPSWD.HTM
This line actually invokes an HTML page. In this example,
the page is currently stored in the HOST file system's O: drive. You can
access any page that is stored in a local MultiValue data file, or that
is accessible through host file system or PicLan DSG functions. This web
page happens to have an HTML <form> that includes two data entry fields
named CUST.ID and CUST.PSWD. The data from
these two fields will automatically appear in the CUST.ID
and CUST.PSWD mv/BASIC variables
012 READ CUST FROM CUST.FILE , CUST.ID ELSE
013 ERRSTR = 'Bad Customer Number'
014 _PAGE HOST O:/WWW/APP/CUSTERR.HTM
Here we have attempted to read the CUST record
from the open customer data file. If the record is not on file we
call the an error page. The error page can include a merge point
for the variable ERRSTR to display detailed information.
The error page does not have an HTML <form> associated with it, so it
will not return.
015 END
016 *
017 IF CUST<1> <> CUST.PSWD THEN
018 ERRSTR = 'Bad Customer Password'
019 _PAGE HOST O:/WWW/APP/CUSTERR.HTM
If the password in attribute 1 of the customer record does
not match the entered password then we display the error page.
020 END
021 *
022 _PAGE HOST O:/WWW/APP/CUSTDISP.HTM
And finally if the customer id and password are both valid,
we display the requested data to the end-user. You should note that
there is no actual display code here. This is because the CUSTDISP.HTM
page can actually include any element from the CUST.ID
and CUST mv/BASIC variable as a part of the HTML layout
using standard PicLan-IP data merge syntax.