FreedomSoft - "the future is freedom"
Template Before - Data Output

The data to be output on the Template, is controlled via the Command, and via the DatabaseClassList, KeyList, InstanceList, ErrorMessageList, and SequenceList parameters.

The Command parameter can override whatever is contained within the various Lists passed into the Template. The types of output that Command can cause, are:

1. No data will be output.

2. One Instance.

3. All of the data referenced within DatabaseClassList, KeyList, InstanceList, ErrorMessageList, and SequenceList will be output.

4. All of the data referenced within the current Search result will be output.

5. All of the data within a particular Class will be output.

In all of the above, data related to any data output, where the related data is referenced on the Template, will also be output.

To force any of the above five types of output, use the following settings of Command:

1. No data will be output - use Command = 'New'

2. One Instance - use Command = 'Select':InstanceKey

3. All of the data referenced within DatabaseClassList, KeyList, InstanceList, ErrorMessageList, and SequenceList will be output - use Command = 'Go'

4. All of the data referenced within the current Search result will be output - user Command = 'ViewSearch'

5. All of the data within a particular Class will be output - use Command = 'View All'

DatabaseClassList, KeyList, InstanceList, ErrorMessageList, and SequenceList are all related lists. DatabaseClassList is an Attribute or Field marker delimited list, containing a list of Database_Classes or System_Classes. KeyList, InstanceList, ErrorMessageList, and SequenceList are all Attribute or Field and Value marker delimited lists. These four lists are all controlled at the Attribute or Field level by DatabaseClassList. At the Value level, KeyList, InstanceList, ErrorMessageList, and SequenceList contain a list of keys, instances, error messages, and output sequence information for each Database_Class or System_Class.

The data within InstanceList is only used, if there is no related data within KeyList, or there is an error message within the related data in ErrorMessageList. Normally, Freedombase will use the instance key to retrieve the current version of the Instance, as the page is being output. This ensures that the most recent version of the data possible is output. However, when the user has tried to update or delete an instance, and that update or deletion has failed validation, that udpate will not have occurred, and we need to output the invalid data back to the user, instead of what is on file. For that reason, if ErrorMessageList contains related data for an instance in InstanceList, Freedombase will use the instance in InstanceList instead of re-reading the data from file.

When outputting data using these Lists, SequenceList must be set correctly to allow Freedombase to drill to related data. Essentially, SequenceList must contain a list of string values of increasing value. (Numbers are easier to use than strings, and numbers are usually used; but they must be right justified.) Please see the Example below for the correct setting and usage of SequenceList.

To output data for multiple different classes on the one page, without Freedombase drilling to the related classes, SequenceList must be set so that the sequences of the dependant class instances fall between the sequences of the controlling class instances.

For example, if we had two classes - CUSTOMER and ORDER - the sequence values for the CUSTOMER instances could be '1','2', and '3', and the sequence values for the ORDER instances could be '1 1','1 2','2 1','3 1', and '3 2'. In this case, Freedombase would interpret that the first two ORDER instances were related to the first CUSTOMER, as '1 1' and '1 2' both fall between '1' and '2'; the third ORDER would be related to the second CUSTOMER, as '2 1' falls between '2' and '3'; and the fourth and fifth ORDER instances would be related to the third CUSTOMER, as '3 1' and '3 2' is greater than '3'.

By convention all numbers used within SequenceList are right justified, and take six characters per number. So, by convention, the SequenceList entries for the CUSTOMER class used in this example would actually be '     1','     2', and '     3', and the SequenceList entries for the ORDERS class used in this example would actually be '     1      1','     1     2','     2     1','     3     1', and '     3     2'. Six characters are used by convention, as it is unlikely that any application would ever need to exceeed a six digit sequence number when outputting data to a Template.

Please note that the example below was taken from Freedombase running on OpenInsight. Most of the examples within this tutorial are taken from Freedombase running on UniVerse. The BASIC used, and the way some commands are executed, varies slightly between the two systems. However, the logic should still be clear enough to be understood, regardless of which version of multi dimensional BASIC you are used to working with.

Sample code is:

     SUBROUTINE TEAM_REPORT_M_HTM_BEFORE(Command,User,DatabaseeClassList,KeyList,InstanceList,ErrorMessageList,SequenceList,NoUpdateFlagList,SearchFlag,Response,Error,MetaErrorFlag)

$INSERT FREEDOMBASE_DEFINITION

    ThisCompany = FIELD(User,'/',1)

    ProjectOccurrence = 0
    ProjectList = ''
    ProjectOccurrenceList = ''
    EXECUTE 'SELECT TEAMS_PROJECT WITH COMPANY = "':ThisCompany:'" BY SEQUENCE'
    ExitFlag = 0
    LOOP
       READNEXT Key ELSE
          ExitFlag = 1
       END
    UNTIL (ExitFlag) DO
       ProjectOccurrence += 1
       ProjectList<1,ProjectOccurrence> = Key
       ProjectOccurrenceList<1,ProjectOccurrence> = SPACE(6 - LEN(ProjectOccurrence)):ProjectOccurrence
    REPEAT

    * Only output the Project List onto the page. Overwrite any other data that may be in the memory lists.

    DatabaseClassList = 'TEAMS':Delimiter.Name:'PROJECT'
    KeyList = ProjectList
    InstanceList = ''
    ErrorMessageList = ''
    SequenceList = ProjectOccurrenceList

    RETURN

  END

previousnext
123456789101112131415161718192021222324252627