[Updated with new version that calculates duration NOV17]
A simple workspace with cues you can cut and paste into your cue lists to log times to a text file. Creates or opens a file on the desktop, called SHOW LOGGER. Here it is in action:
How it Works:
Adapted from script at http://www.macosxautomation.com/
You can download the workspace here
Log with Calculations
You can build on the above workspace to add calculated running times to the log.
Unix Epoch time is defined as the number of seconds since midnight at the start of January 1, 1970
Show File Name
The Show file name is taken from the workspace file name
Tbe data is written to the logging file with this
The log cue scripts are all identical with the exception of the text to be logged and cues they reference:
In the above example themessage is set to “Curtain up”. The time as a string is appended to this and the whole string is written to the log file.
Then the epoch seconds are obtained by running a shell script
set notes of cue “LOG1” to (do shell script “date +%s”) as integer
Which gets the epoch seconds and writes them to the notes cue.
Adding Log Cues
If we wanted to modify this script to log the House Open time we would:
Copy and paste cue LOG1 in the cue list to create a new cue which we number LOG0
Change the first line of the script to: set themessage to “House Open”
and the shell script line to: set notes of cue “LOG0” to (do shell script “date +%s”) as integer
The report cues are again, similar
A variable, thesecs, is set to the value of the calculation. In the above example, (notes of cue “LOG2”) – (notes of cue “LOG1”), to get the act 1 running time in seconds by subtracting the value of the notes field of cue “LOG1” from the value of the notes of cue “LOG2”,
The result in seconds is then converted to a string to give the duration in a more readable format, HH:MM:SS
This is then put into a data string with a string identifying what the duration refers to, and written to the log file
Adding Report Cues
Again, these scripts are easily modified to report other durations e.g to create a cue which logged the length of the pre show, from house open to curtain up you could:
Copy and paste cue LOGA in the cue list to create a new cue which we could number LOGZ
change the calculation line to:
set thesecs to (notes of cue “LOG1”) – (notes of cue “LOG0”)
set the 2 instances of cue “LOGA” in the script to cue “LOGZ”
Change the text, ” ACT1 Running Time: ” to ” PRESHOW Running Time: ”
To enable the log and report cues to be cut and pasted to anywhere in the cue list, every cue contains the script instructions to write the data to the show log file. This means that you could, for instance, write the interval time duration straight after you logged the curtain up act 2 time. Because each cue will open and close the log file for writing you need to leave time for this to happen before sending another cue that writes to the file. This is best achieved by putting any multiple log cues into a group and using predates to separate them by a second or so.
You can download the v2 workspace with the calculate and report additions here
Refining The Scripts
The flexibility of every cue being self contained and capable of doing everything it needs to within its own script is useful. In certain circumstances e.g where we had a lot of log cues and complex reports, there would be a lot of duplicated code in the scripts. If we wanted to amend something in all the scripts, e.g change the path or name of the file that cues logged to, or even send email notifications with durations as soon as they are logged, then there would be a considerable amount of changes to duplicate scripts.
If we were writing our workspace as a conventional computer programme, we would, as far as possible, only have one instance of code for each task, e.g writing to a file, converting seconds to an hh:mm:ss string etc. We would achieve this by calling subroutines and functions. Because in QLab variables are only preserved within their own cues, there is no straightforward way to have blocks of script shared between cues.
However, in the same way we used cue’s notes fields to hold variables we can also use these fields to pass variables from script cues to other script cues containing subroutines, and back again.
This has the disadvantage that, without the cues containing the subroutines being present in the workspace, the main script cues would be unable to function, but this has many potential uses so we will explore another version of this workspace which uses this idea.
We will also refine the log and report cues so that any information that needs to be changed in duplicated cues, e.g. to change the report structure to 3 act play with 2 intervals is put at the top of the scripts, and is clearly annotated, so it is not necessary to hunt through the script to find variables and strings that need to be changed for the new use.
The new cue list with the added subroutine cues now looks like this:
The new cues can be anywhere in the workspace. You could create a new cue list called something like logging helpers if you didn’t want them in your main cue list. If you were going to use this extensively then you could put the whole of this list in a logging cue list in your template file, and then just cut and paste the LOG cues in to the main cue list as needed., or use start cues in the main list to trigger them.
The cue CALC 1 contains the script to convert seconds to a string in HH:MM:SS format
It uses the notes field to receive the value from the cue which triggers it (the calling cue) and returns the value to this field.
The cue WRITE works in the same way using the notes field for the message it is going to write
Here’s the much shorter script for one of the logging cues:
It formats the data it wants to write into a string and sets the notes of cue “WRITE” to that string. It then starts the cue “WRITE”
The report scripts look like this:
This performs the calculation of duration as in our previous examples and sets the notes field of cue “CALC1” t the result
cue “CALC 1” is then started and that cue returns the HH:MM:SS string by setting its notes field to the result
The cues name field as the name of the duration in the message (padded with leading spaces by the repeat loop near the top of the script) and includes this together with the calculation of duration result in the string that the notes field of cue “WRITE” is set to.
You can download this workspace here
Cover Image:photo taken by Georges Jansoone on 26 May 2005 distributed under a Creative Commons Attribution Share Alike Unported license. Modified image by Mic Pool distributed under the same license.