Record Sets Commentary

General:. Record Sets in Glee are like tables of structures in other languages. A Record Set is composed of two objects: (1) A field list (naming fields within records), and (2) a sequence of records(which are themselves sequences of data elements in field order). A Record Set can be viewed as a table with named columns. Glee facilitates creating the Record Set; defining its fields; populating its records; adding, deleting, and renaming fields; replacing and deleting records; and retrieving by field, by record, or by combination of both. Glee Record Sets do not impose discipline on the data. They merely provide a mechanism for naming and thereby referring to elements of a record sequence. For example, you can put string data where numerics belong and the Record Set does not debate. Glee will, however, assure that there is a correspondence between the field names and the fields in all the records. When data is submitted, Glee scans it for conformance and rejects all or accepts all. If rejected, a diagnostic is given and the program is interrupted. Use of Record Sets can make programs more readable.





Create Record Set (#RS): The niladic operator "#RS" creates a Record Set with no fields and no records. It is simply a composite object with an empty field list object and a record sequence containing no elements. You can assign this to a variable which can then be the target for populating the Record Set.




Add fields to new Record Set: Fields are added to Record Sets by assigning to an empty Record Set index. You can add fields at any time. Glee checks to be sure the field you are adding is not already part of the Record Set object. If it is, a diagnostic is given and the program is interrupted. If not, the field is appended to the field list for the Record Set. If the Record Set contains records, new items are appended to each record. These items are a null objects.




Add Records: Data records are added to Record Sets by assigning to an empty Record Set index. This is the same method we used for adding fields. When you append new records to the Record Set using null indexing (i.e. []) the field order of the Record Set is assumed. This can be obtained using the .fields property for the Record Set (e.g. rs.fields).




Rearranging and deleting fields in a Record Set: Record Set fields are maintained in the order in which they are supplied. New fields are appended to the field list. If you want to change this order or remove fields, you do so by field indexing into the Record Set. This creates a new Record Set in the new order. You can then replace the existing Record Set with it. Record Sets are just collections of pointers. However, when you rearrange fields, you are rearranging the elements of the record sequences as well. If the Record Set is very large, this is probably not a good idea. Records Sets should probably not be allowed to grow to great size. They are intended for managing small tables of data.




Create with field list: It is common to create the Record Set with its initial complement of fields rather than to add fields later.




The .recmethod and mnemonic programming: You can construct more readable and managable programs using mnemonic techniques. This example shows how you can get an empty record structure from the Record Set using the .rec method. A copy of the Record Set is returned which contains just one record of which all fields are null objects. You can then mnemonically index the field data into this record and then append it to the record set. This technique might be useful for creating records and populating them as data is entered into a form.




Get Fields: When you get information from a Record Set you are given a completely new Record Set. Typically you'll only be interested in the records part (presumably you already know everything about the fields part). See the next example for how to get just the records part.




The .rec and mnemonic programming: You can construct more readable and managable programs using mnemonic techniques. This example shows how you can get an empty record structure from the Record Set using the .rec method. A copy of the Record Set is returned which contains just one record of which all fields are null objects. You can then mnemonically index the field data into this record and then append it to the record set. This technique might be useful for creating records and populating them as data is entered into a form.




The .recs and .fields properties: When working with the data in the Record Set, you usually only want the "sequence of records" part. The ".recs" property returns this. If you want the field list part, the ".fields" returns that. These are not references. You can't change data in this result and expect it to change in the original Record Set.




Addressing: Addressing in Record Sets can be by record(s); by field(s); or by a combination as shown here. When using the combination, specify the field(s) together (in the order you want) and the record number(s) (in the order you want). It doesn't matter which order you use (fields first or record numbers first). In fact you can mix them up but I don't recommend that.




:




: