Templates

Advanced techniques

Here are techniques used on templates which can be considered advanced - they are not obvious from the individual script keywords and can be tricky to get right. Two techniques are explained here:

  • Frames of adjustable height
  • Substituting fields into a text line

Frames of adjustable height

When putting text on a template you usually have an idea of how long the text will be when printed on the report and how much space is required. For example, a heading for a student name followed by the name of the student is nearly always a single line of text and you can estimate in advance how far across the page it will go.

For longer pieces of text that require more than one line, you can set the size of the frame to fit the most number of line that you want to allow, but there are cases where this approach can be a problem.

For example, with Areas of Assessment (outcomes) on a report some course may have many short outcomes, while another course may have less outcomes but each outcome is much longer. In this case, if the frames on the page are large enough for the longest outcome, then not many outcomes will fit, but if the frames are small enough to fit the maximum possible number of outcomes a course may need, then the longer outcomes will not fit.

  • The solution is a frame that can adjust its height to fit the longer text.

Before showing the solution here is a simple way to show an outcome have a set of five boxes next to it so a tick can appear to show the level of achievement. The first three line set up size of the text of the outcome and prepare the /hgraph/ keyword for printing ticks. Then the outcome is printed and the tick put in the appropriate box (depending what the teacher entered). And lastly, the two /grid/ lines draw the row of the table for the outcome and the five tick boxes.

/serif/,10
/left/
/graph/,area,wingcheck
/****/,----------- first outcome -----------
/field/,strand1,10,10,1250,70
/****/,preview,graph,1,5
/hgraph/,level1,1,1300,0,1800,70
/grid/,0,0,1300,70,1,1
/grid/,1300,0,1800,70,5,1

In these lines the height of the frames for the text of the outcomes is just less than 7 mm. Which may be only 1 line at the current font size. But if the outcome stored in Strand 1 is longer than this, it will not fit and the report won't look right.

Below are lines from a template that also shows a row of the outcomes table to be 7 mm high, if the outcome will fit in that space but which will also stretch the height of the row up to a maximum of 30 mm to allow longer outcomes to fit. What in the example above took four lines of script, now requires 20 lines and is a lot more complicated.

/serif/,10
/left/
/graph/,area,wingcheck
/control/,adjustpara,2,70
/text/,10,-70,1250,0," "
/****/,----------- first outcome -----------
/adjust/,10,y1,1250,y2,absolute
/field/,strand1,newpara,300
/control/,push
/adjust/,1300,y1,1800,y2,absolute
/control/,push
/adjust/,0,0,0,0,70
/****/,preview,graph,1,5
/hgraph/,level1,1,last
/control/,pop
/adjust/,0,y1,1300,y2,absolute
/grid/,last,1,1
/adjust/,1300,y1,1800,y2,absolute
/grid/,last,5,1
/control/,pop
/****/,...
/****/,more outcomes
/****/,...
/control/,adjustpara,0

This is why it is an advanced technique, you can see an example of this used in the Sample Subject template. Here is an explanation of how this works. The three keys lines are:

/control/,adjustpara,2,70
/field/,strand1,newpara,300
/control/,adjustpara,0

The first /control/ line initialises the adjustable frames. The adjustpara control starts turns on the adjustable frames where 70 means the frame has a minimum height of 7 mm and the 2 adds a little padding between the frames so there is a small space between the outcomes.

The last /control/ line uses 0 to turn off the adjustable frames. If there is more than one outcome the idea is to have the similar lines repeated for each outcome (changing the /field/ and /hgraph/ lines to be the next outcome, strand2 etc).

Between those two lines is the /field/ line that instead of including the coordinates has newpara followed by 300. The 300 means the frame can stretch to 30 mm if necessary and newpara is what indicates it is an adjustable frame.

The rest of the extra lines are to ensure the /grid/ lines draw rows of the table that are the correct height for the text. To do this combinations of /adjust/ and /control/,push and pop are used. Further comments about this template script can be found in the Sample Subject - Commented template.

Substituting fields into a text line

There are two main times you need to be able to substitute fields into a text line.

  • When a field such as a student's name needs to be included in piece of text.
  • When a field can vary in length and you want to have a heading that is adjacent to the text.

For example, on a report a statement may be made about a student's attendance and you want the name of the student to be included in the text. An example of the second, is the name of the class teacher that is right justified and has a heading on its left. If you position the heading far enough to the left to allow for the longest possible teacher name, then when there is a short name there will be a large unattractive gap.

  • In both cases the solution is possible with the subtext option of the text keyword.

There is no easy way to do the first example without using the substitution technique, so here is the solution immediately.

/field/,preferred,0,0,0,0
/field/,attendance,0,0,0,0
/text/,0,0,1800,100,"subtextDuring this semester ^ has been absent for ^ days."

The way this works is that any /field/, /column/ or /title/ keyword line that has a frame of zero size, i.e. coordinates of 0,0,0,0 does not print the information on the report but instead stores the contents of the field in a list. So here the preferred name of the student is put first in the list which is followed by the number of days absent from the attendance field. The list is kept until a /text/ keyword line has text that begins with subtext.

Then when the subtext line is printed (you do not need a space after subtext) each time a ^ is in the text, the next item from the list is substituted.

Here is an example of the second problem. The text is right justified because you want the name to be aligned with the right edge of the report, but because you want to allow enough room for the longest teacher name the Teacher heading is 40 mm from the right edge which leaves a large gap when the name is short.

/serif/,10
/right/
/text/,1000,0,1400,70,Teacher:
/field/,teacher,1410,0,1800,70

Below is the way to do is by substituting text which right justifies the line and keeps the space between the heading and the teacher name the same no matter how long the name is.

/serif/,10
/right/
/field/,teacher,0,0,0,0
/text/,1000,0,1800,70,"subtextTeacher: ^"

 

Contents
Search