TQS Home
Trivia Quiz Shell Version 2.8 Now Available!Bot Productions Home

Part VIII: Creating a Location Hierarchy

When creating a large TQS application with many locations, you may find that putting all of the LOC elements together adds disorganization to your TQS document. For instance, if you are creating an application to go with a textbook, you may wish to divide locations into chapters, and then further divide chapters by subtopic. TQS allows you to nest LOC elements to better organize your document.

Although the internal structure does not have noticable effects on the user's perception of the application, using an hierarchial organizational system makes your document easy to author. Also, as will be seen in the next part of the tutorial, there are some additional benefits to such organization.

Nesting locations is accomplished by putting LOC elements inside other LOC elements. The outer LOC element's TYPE attribute must be set to "NULL". Its ID attribute must be set to a single, unique value; that is, within the current hierarchy level, IDs must be unique.

Let's update our TQS document to include a location hierarchy as follows:

<LOCATIONS START="0">
  <LOC ID="0" TYPE="MENU">
    <HEADING>My Main Menu</HEADING>
    <MENU CENTER="1">
      <MENUITEM
        TITLE="United States"
        TARGET="1,0"
      />
      <MENUITEM
        TITLE="Europe"
        TARGET="2,0"
      />
    </MENU>
  </LOC>
  <LOC ID="1" TYPE="NULL">
    <LOC ID="0" TYPE="MENU">
      <HEADING>United States Menu</HEADING>
      <BUTTON TITLE="Main Menu" TARGET="0"/>
       <MENU CENTER="1">
         <MENUITEM
           TITLE="U.S. Hangman"
           TARGET="1,1"
         />
         <MENUITEM
           TITLE="U.S. Trivia"
           TARGET="1,2"
         />
       </MENU>
    </LOC>
    <LOC ID="1" TYPE="HANGMAN">
      <HEADING>United States Hangman</HEADING>
      <BUTTON TITLE="Main Menu" TARGET="0"/>
      <BUTTON TITLE="U.S. Menu" TARGET="1,0"/>
      <HANGMAN>
        <WORD>ALABAMA</WORD>
        ...
      </HANGMAN>
    </LOC>
    <LOC ID="2" TYPE="QUESTIONS">
      <HEADING>United States Trivia</HEADING>
      <BUTTON TITLE="Main Menu" TARGET="0"/>
      <BUTTON TITLE="U.S. Menu" TARGET="1,0"/>
      <QUESTIONS>
        ...
      </QUESTIONS>
    </LOC>
  </LOC>
  <LOC ID="2" TYPE="NULL">
    <LOC ID="0" TYPE="MENU">
      <HEADING>Europe Menu</HEADING>
      <BUTTON TITLE="Main Menu" TARGET="0"/>
       <MENU CENTER="1">
         <MENUITEM
           TITLE="Europe Hangman"
           TARGET="2,1"
         />
         <MENUITEM
           TITLE="Europe Trivia"
           TARGET="2,2"
         />
       </MENU>
    </LOC>
    <LOC ID="1" TYPE="HANGMAN">
      <HEADING>Europe Hangman</HEADING>
      <BUTTON TITLE="Main Menu" TARGET="0"/>
      <BUTTON TITLE="Europe Menu" TARGET="2,0"/>
      <HANGMAN>
        <WORD>GERMANY</WORD>
        ...
      </HANGMAN>
    </LOC>
    <LOC ID="2" TYPE="QUESTIONS">
      <HEADING>Europe Trivia</HEADING>
      <BUTTON TITLE="Main Menu" TARGET="0"/>
      <BUTTON TITLE="Europe Menu" TARGET="2,0"/>
      <QUESTIONS>
        ...
      </QUESTIONS>
    </LOC>
  </LOC>
</LOCATIONS>

While this code may look somewhat intimidating, it is rather straightforward. The first LOC element has an ID of "0" and represents the main menu. The second LOC element has an ID of "1" and contains two sublocations. Each of these sublocations must have a unique ID within their grouping.

Notice how the TARGET attributes for MENUITEM and BUTTON elements have changed. The main menu ID has stayed the same, but the others now include two numbers, separated by a comma. The TARGET="2,1" refers to the LOC element with ID of 1 inside of the LOC element with ID of 2; in our case, the Hangman location within the Europe category.

Depending upon the structure of the program you want to design, you may want to nest even further; there is no limit to how deep you can nest LOC elements. To refer to a LOC element inside of another, you simply add a comma and the sublocation's ID.

It is important to note that LOC elements which contain other LOC elements cannot contain any data; they cannot be navigated to.

Part VIII of the tutorial has explained the idea of nesting LOC elements to create a location hierarchy. Remember that the end user experience will not be affected by how you choose to organize your locations; however, there are benefits to using such a hierarchy, as will be explained in the next part of the tutorial. Global settings and buttons are the focus of Part IX.

Part IX: Global Settings and Buttons

©2020 Bot Productions. All rights reserved.Last Updated: September 9, 2007