Add a linked database
Modify the code again to add a linked file. The ITEMS file
is linked to the TOPICS file by the field TOPIC.
This modification will:
1. step through the TOPICS file on record at a time and output
a TOPIC
2. step through the ITEMS file one record at a time and output
all the items associated with the current
topic in alphabetical order using the index TOPIC_ITEM.ITEM.
See figure 9 for what the page would look like in a Netscape
browser.
SUB PROJ1(RetValue$)
CALL HTML("<HTML>")
CALL HTML("<HEAD><TITLE>")
CALL HTML("Project 1 code generated page")
CALL HTML("</TITLE></HEAD>")
CALL HTML("<BODY>")
CALL HTML("<H1>These topics are available:</H1><HR>")
IF NOT OPEN ("TOPICS") THEN OPEN FILE DIRECTORY
+ "\SAMPLES\TOPICS.SBF"
IF NOT OPEN ("ITEMS") THEN OPEN FILE DIRECTORY
+ "\SAMPLES\ITEMS.SBF"
FILE "ITEMS"
INDEX TOPIC_ITEM
FILE "TOPICS"
INDEX TOPIC
SELECT FIRST FILE "TOPICS"
WHILE NOT EOF ("TOPICS")
CALL HTML("<B>" + TOPIC.TOPICS + "</B>")
FILE "ITEMS"
SELECT FIRST FILE "ITEMS"
SELECT KEY TOPIC.TOPICS
WHILE TOPIC.ITEMS = TOPIC.TOPICS AND NOT EOF ("ITEMS")
CALL HTML("<BR>")
CALL HTML(ITEM.ITEMS)
SELECT NEXT FILE "ITEMS"
WEND
SELECT NEXT FILE "TOPICS"
CALL HTML("<P>")
WEND
CALL HTML("</BODY></HTML>")
END SUB

Figure 9: Current
display of code generated WEB page
|