SUBROUTINE INSERTCONVITEM
* Insert a preprepared web page using RW_INSERT_CONV_ITEM.
* Use the aTokens and aValues parameters to apply a stylesheet
* and to insert data extracted from a Reality file.

* Include the RealWeb definitions
INCLUDE #RW.INCLUDE.DEFS FROM /SYSFILES/REALWEB,BP

EQU AM TO CHAR(254)
EQU TAB TO CHAR(9)

* Get the URL of the Reality item server.
STYLESHEET = ""
CALL RW_GET_PARAM("__isurl", STYLESHEET)
* Specify the location of the stylesheet.
STYLESHEET = STYLESHEET : "/REALWEB-ITEMS/styles.css"

* Set up the aTokens array to contain the tokens used in the
* web page.
TOKENS = "STYLESHEET"
TOKENS<-1> = "NAME"
TOKENS<-1> = "ADDRESS"
TOKENS<-1> = "TOWN"
TOKENS<-1> = "DATE"

* Get some data to insert.
PERFORM "LIST-SPREAD GUESTS '122'" CAPTURING VALUES
* The data is in the third attribute.
VALUES = VALUES<3>
* LIST-SPREAD returns tab-separated data; we need a dynamic array.
VALUES = CHANGE(VALUES, TAB, AM)
* The first attribute is the item-id, which we don't need; we need
* it to be the styelsheet URL.
VALUES<1> = STYLESHEET

* Insert the web page with the stylesheet and data inserted.
CALL RW_INSERT_CONV_ITEM("REALWEB-ITEMS", ...
"personal_details.htm", ...
TOKENS, ...
VALUES, ...
"#", ...
RWD_NORMAL)
RETURN

The item "personal_details.htm" contains:

<html>

<head>
<meta http-equiv="Content-Language" content="en-gb">
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>Personal Details</title>
<link rel="stylesheet" type="text/css" href="#STYLESHEET#">
</head>

<body>

<h2>Personal Details</h2>
<p>Name: #NAME#</p>
<p>Address: #ADDRESS#</p>
<p>Town: #TOWN#</p>
<p>Start date: #DATE#</p>

</body>

</html>