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

Part XV: Embedding Files in TQS Applications

TQS 2.6 introduces a powerful new feature that makes distributing your TQS applications easier. TQS allows you to use images and sounds in your application; however, prior to TQS 2.6, you always had to distribute these additional files along with your TQS application. Now, you can embed these files directly into your TQS application files (.tqs).

The FILES element, a child of the TQS element, holds all embedded files. Each embedded file has a FILE element, whose NAME attribute lists the name of the file. The actual contents of the element are the exact contents of the file, encoded in Base64 format.

<FILES>
  <FILE NAME="file1.gif">/9j/4AAQSkZJ ...</FILE>
  <FILE NAME="file2.gif">2wBDAQMEBAUE ...</FILE>
  ...
</FILES>

TQS 2.6 includes the TQS Embed Utility, which allows you to do the following:

  • Add files to a TQS application
  • Remove files from a TQS application
  • Rename embedded files
  • View embedded images and listen to embedded sounds

You should always use the TQS Embed Utility, and not attempt to modify the FILE elements yourself.

Before opening the TQS Embed Utility, open your TQS document (tutorial.tqs) in Notepad, and set the VERSION attribute of the TQS element to 2.6. This is required to support embedded files. Also, be sure the EDITABLE attribute is set to "1", so that the TQS Embed Utility can edit the document.

Save your TQS document and close Notepad, and then open the TQS Embed Utility by choosing it from the Start Menu's Trivia Quiz Shell folder. (If the utility is not listed, you need to download and install the setup package that contains the utility.)

Click the Open... button and open up tutorial.tqs.

Note that the embedded files list is currently empty. Click the Add Files... button and select an image file to add to your application. Then, select the file and click the View File button.

The View File button also allows you to listen to embedded sound files. Use the Add Files... button to add a MIDI file to your application, then select it and click View File again.

Now that you've added a few files, save your application and exit the TQS Embed Utility. Open up your application in Notepad, scroll to the end of the file, and note the new FILES and FILE elements.

Next, let's see the embedded files in action. Make the following changes to the XML code:

  • Set the BGIMG attribute as follows, using the name of the image file you embedded:
    <TQSWINDOW BGIMG="EMBED?Green-Foliage.jpg" .../>
  • Add a BGSOUND element as follows, using the name of the sound file you embedded:
    <BGSOUND>EMBED?flourish.mid</BGSOUND>

Run your TQS application, and you will see the embedded background image and hear the embedded sound file.

Embedded images can be used as background images, heading images, Hangman images--in any place where images can be used. Likewise, embedded sounds can be used as the background sound, correct/incorrect sound, or within custom locations. The EMBED? prefix shown above is what tells TQS that the file is embedded and not an external file.

To use embedded files within HTML and custom locations, you must use the EMBEDROOT dynamic value as a prefix to the desired file. For instance:

<HTML SUBST="%embed%,EMBEDROOT">
...
<img src="%embed%img.gif"/>
...
</HTML>
img.src = getDynVal("EMBEDROOT") + "img.gif";

This section of the tutorial has described how to use the TQS Embed Utility to add files to your TQS applications, and how to use these files within your TQS locations. The next part of the tutorial introduces new features of TQS 2.7.

Part XVI: Advanced TQS Window Options

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