Figure 7: RPG source code for program ITEMLOOKUP
|
*=====================================================================
|
FITEMS1 IF E K DISK EXTFILE('MYLIB/ITEMS1')
|
A |
|
*=====================================================================
* Includes to be used in CGIs
*=====================================================================
/copy mysource/CGIDEV2
|
B |
|
D imagelink S 100
D request S 10
|
C |
/free
|
clrhtmlBuffer();
IfsMultIndicators =
GetHtmlifsMult('/itemlookup.html /errorforms.html');
|
D |
|
// The variable request holds the result of ZhbGetVar,
// which determines whether the program was sent a value
// for the HTML form field called Request.
request = ZhbGetVar('request');
select;
// Determine the action requested.
when request = 'lookup';
|
E |
|
// Get the requested item number from the HTML form.
number=ZhbGetVar('number');
// Get item record.
chain number itemsr;
|
F |
|
// If found, update variables and write out a new HTML page.
if %found(items1);
updHTMLvar('number': number );
updHTMLvar('desc' : descript );
updHTMLvar('price' : %editc(salesprice : '3');
imagelink = '/js/' + image;
updHTMLvar('image' : imagelink );
WrtSection('resultform');
|
G |
|
// If not found, display error page.
else;
updHTMLvar('number': number );
WrtSection('notfound');
endif;
|
H |
|
// No request was sent, so write the initial request page.
other;
//Write the initial form that asks for an item number.
WrtSection('initialform');
endsl;
|
I |
|
//Write the end of the form (required with CGIDEV)
WrtSection('*fini');
*INLR = *ON;
/end-free
|
J |
|