In this sample application, each of the subscribers can subscribe to several different magazines. This requires a second RMSfile which contains all the magazines that a subscriber may receive. It contains a code for each magazine along with its title, subscription rate and the like. The fields in the magazine RMSfile are:
magazine, 16 character string
magazine code
title, 36 character string
magazine title
year_rate, money
rate for one year's subscription
subscribers, integer
number of subscribers to this magazine
The magazine RMSfile in the demo database is named mag. The subscribers field in the mag RMSfile is used in a later example.
Also needed is a third RMSfile which keeps track of the subscriptions for each of the subscribers. The fields in that RMSfile are:
subscriber, 16 character string
subscriber code
magazine, 16 character string
magazine code
issues, integer
number of issues left in subscription
started, date
date subscription was started
The subscription RMSfile in the demo database is named script. There is one entry in this RMSfile for each of the magazines that each subscriber receives.
The formfile for entering magazines into the mag RMSfile is straightforward and is not covered here. For a detailed description of creating this formfile, see "Creating the Magazine Form" in C/Base Tutorial Manual Chapter 4, Creating the Demonstration System Form. As an additional guide, we show here the magazine formfile mag provided with the Demonstration Subscription System. Figure 10 below is the output from the pform command which lists the contents of a formfile.
Contents of formfile mag
Form Name: mag
Data File: mag
Beginning form yes Unique records yes
Repeating form yes Append form no
Freeze form no Multiple record no
Next form name: mag
Line 3, Column 22, Field name: magazine , Field length 15
Entry Allowed yes Input required yes
In Data File yes Invisible no
Line 5, Column 22, Field name: title , Field length 35
Entry Allowed yes Input required yes
In Data File yes Invisible no
Line 7, Column 22, Field name: year_rate , Field length 14
Entry Allowed yes Input required no
In Date File yes Invisible no
Line 9, Column 22, Field name: subscribers , Field Length 5
Entry Allowed no Input required no
In Data File yes Invisible no
Figure 10
A subscription formfile is also simple to create. Only a picture of the final screen is shown here:
This subscription form, however, presents some interesting problems. All the subscriptions entered into the script RMSfile should belong to valid subscribers, i.e., subscribers that have already been entered into the sub RMSfile. Also, the subscriptions entered should only be for magazines that have been entered into the mag RMSfile. As an additional check for the user, the magazine title should be displayed when the magazine code is entered, so that it is easy to tell that the correct magazine code was entered.