TSSSX Scripting Overview

Introduction

The TSSSX Object Model has been published so you can create your own customized website and reports from data stored in the scheduling project. Scripting is currently used to generate the project website, and to run the custom reports. If you would like to customize the look and feel of the website, add more columns or hide some data, you will need to edit the source Round Robin Scheduler Report Template File (.TRT for short). This section will try to explain what makes up a TRT file, how it is run, and what you can do with it. This documentation assumes you already know HTML and JavaScript (or another programming language).

The Round Robin Scheduler Report Template File (TRT File)

A TRT File is a simple text file with code blocks. Code blocks are denoted by the <% and %> tags. Anything between those two tags must be valid code. Currently JavaScript and VBScript are supported. An example of a TRT File:

This is normal text in a text file.
<%
// the default language is JavaScript
Response.WriteLine("This is text in a javascript code block.");
var i;
for (i = 0; i < 3; i++)
{
Response.Write(i + " ");
}
%>

The above code would output the following result:

This is normal text in a text file.
This is text in a javascript code block.
0 1 2

Using JavaScript in TRT Files

By default JavaScript is used as the scripting language in a TRT file. The can also be explicitly set by adding the following directive to the first line of a TRT File:

<%@ Language=JavaScript %>

Using VBScript in TRT Files

To use VBScript as the scripting language in a TRT file, add the following directive to the first line in the file:

<%@ Language=VBScript %>

Note that this directive sets the language for all script blocks in the file. You can't use both JavaScript and VBScript code blocks in the same file. Since all supporting functions are written in JavaScript, it is recommended you use JavaScript when authoring TRT Files that will depend on the existing codebase.

Special Processing Instructions

To generate the website, a few special instructions needed to be introduced. Namely, running the same report for every item type in the project (i.e. running the team.trt web page report for every team in the project). These special processing instructions are described below.

Processing Instruction Description
CONTEXT-LOOP

The context-loop tag tell RRS to repeat the report for every item specified in the context-loop. Also, a global variable is added to the report so the script can access the current item. Listed below is a table containing the Value that can appear between the context-loop tag, the associated Global Variable Name that will be available in the script, and a Description of what is looped through.

Value Global Variable Name Description
leagues League Loops through all the leagues in the project.
teams Team Loops through all the teams in the project.
divisions Division Loops through all the divisions in the project.
venues Venue Loops through all the fields in the project.
officials Official Loops through all the officials in the project.
games Game Loops through all the games in the project.
contacts Contact Loops through all the contacts in the project.
sponsors Sponsor Loops through all the sponsors in the project.
masterschedules MasterSchedule Loops through all the master schedules in the project.
seasonschedules SeasonSchedule Loops through all the season schedules in the project.
practiceschedules PracticeSchedule Loops through all the practice schedules in the project.
tournamentschedules TournamentSchedule Loops through all the tournament schedules in the project.

For Example:

<CONTEXT-LOOP>leagues,teams</CONTEXT-LOOP>

The above example combined two values to create two loops. This example would have the current report repeated for every team in every league. The current league and team can be accessed in the report by the League and Team global variables.
FILENAME The filename tag allows you to specify the filename and extension to use for the report. If the filename tag appears in a script containing a CONTEXT-LOOP tag, the context-loop item's ID is prepended to the filename. For example:

<FILENAME>schedule.csv</FILENAME>

The above tag would have the reported saved as 'schedule.csv'.
RRS-INFO RRS looks for this section in a Report TRT file so it knows the type of output, and can display the description and author information to the end user. The following tags are supported inside the <RRS-INFO> </RRS-INFO> tags:
  • <description>Describe what the report does.</description>
  • <copyright>Enter any copyright notice.</copyright>
  • <author>The author of the report.</author>
  • <date>The date the report was written.</date>
  • <output>The mime-type output format. text/html or text/plain are supported.</output>
<!--# include file="filename.inc"--> Use this syntax to include another file into the report.
<%=  someVariable %>

This is shorthand notation which writes out the someVariable variable to the output file. This gets translated to:

<% Response.Write( someVariable ) %>

Support Functions available in the Include Files

There are a number of helper functions available in the serverscripts.inc include file. These include date & time formatting functions. You can add your own functions to serverscripts.inc, or add them to the clientscripts.inc file.

Built-In Global Variables

There are three built-in global variables which are available in every script. These are listed below.

The globals.inc File

The globals.inc file contains global variables which are currently used by some of the functions in the serverscripts.inc file. Current settings to swap the Home/Away columns (so the Away column is before the Home column), and which Date & Time formats should be used. If you need to add global settings that will be available to all scripts, add them to this file.

How it all Works

The Round Robin Scheduler parses the data in the TRT file, wraps all the normal text in a code block, combines all the code blocks together with the included files, and inserts it into the base trt file (which contains the logic for creating the output files and loading the scheduling project), and then runs the resulting file through Windows Script Host. The temporary script and report files RRS creates are deleted when the program is closed.

More Information

The best examples are working examples. Check out the .TRT files used to create the website in the RRS Folder\Templates\Default, and the custom reports in the RRS Folder\Reports.

 


Note: Some features described in this help file are only available in the Team Sports Scheduling System.