Jump to content

QLab - Applescript - Show Timings


Recommended Posts

Hey guys,

 

I am not sure if this is the best forum for applescript users however I have an applescript question.

 

I am looking to use applescript in QLab to write to a txt file with the Up and Down times of each act and from this work out the duration of each act.

 

I have with the following code in cues managed to successfully write to a file the show title, venue and the Act 1 Up, Act 1 Down, Act 2 Up and Act 2 Down times for each performance in a text file named Show Times.txt on the desktop.

 

My issue is, if you wish to try the code for yourself, that I cant figure out how to work out the difference in times between act1down and act1up and the same for act 2. I understand applescript works things out in seconds but from then on it gets a bit to confusing for me. Any help is appeciated and of course for all you QLab users I will drop all finalised code in to aid all you SM's out there with your up and down times for performances.

 

Q1 - DOORS

--VARIABLES SET HERE
set show_name to "SHOW NAME GOES HERE"
set show_venue to "VENUE NAME GOES HERE"

-- CODE
set fileTarget to (path to desktop folder as text) & "Show Times.txt"

try
fileTarget as alias
on error
tell application "Finder" to make file at desktop with properties {name:"Show Times.txt"}
end try

try
set theFile to (((path to desktop) as text) & "Show Times.txt") as alias
set t to (time string of (current date))
set d to (date string of (current date))
set N to open for access theFile with write permission
get eof N
if result = 0 then
	write "- - - - - - - - - - - - - - - - - - - - - - - - - - -" & return to N
	write "Show Name: " & show_name & return to N
	write "Venue: " & show_venue & return to N
	write "Date: " & d & return to N
	write "Doors handed over at: " & t & return & return to N
else if result > 0 then
	set theText to read N
	set eof N to 0
	write theText & return & return to N
	write "- - - - - - - - - - - - - - - - - - - - - - - - - - -" & return to N
	write "Show Name: " & show_name & return to N
	write "Venue: " & show_venue & return to N
	write "Date: " & d & return to N
	write "Doors handed over at: " & t & return & return to N
end if
close access N
end try

 

 

Q2 - Act 1 Up

try
set theFile to (((path to desktop) as text) & "Show Times.txt") as alias
set t to (time string of (current date))
set N to open for access theFile with write permission
get eof N
if result > 0 then
	set theText to read N
	set eof N to 0
	write theText to N
	write "Act 1 Up: " & t to N
end if
close access N
end try

 

 

 

Q3 - Act 1 Down

try
set theFile to (((path to desktop) as text) & "Show Times.txt") as alias
set t to (time string of (current date))
set N to open for access theFile with write permission
get eof N
if result > 0 then
	set theText to read N
	set eof N to 0
	write theText & return to N
	write "Act 1 Down: " & t to N
end if
close access N
end try

 

Etc for act 2 and for the final cue at present for displaying a dialogue box for showing times I have:

 

Q6 - Show Report

set fileTarget to (path to desktop folder as text) & "Show Times.txt"

set newFile to (fileTarget)
set theFileContents to paragraphs of (read file newFile)

repeat with p in theFileContents
if p contains "Show Name:" then
	set shownamefull to p
	set {TID, text item delimiters} to {text item delimiters, "Show Name:"}
	set showname to text item 2 of shownamefull
	set text item delimiters to TID
else if p contains "Act 1 Up:" then
	
	set act1upfull to p
	set {TID, text item delimiters} to {text item delimiters, "Act 1 Up:"}
	set act1up to text item 2 of act1upfull
	set text item delimiters to TID
	
else if p contains "Act 1 Down:" then
	
	set act1downfull to p
	set {TID, text item delimiters} to {text item delimiters, "Act 1 Down:"}
	set act1down to text item 2 of act1downfull
	set text item delimiters to TID
	
else if p contains "Act 2 Up:" then
	
	set act2upfull to p
	set {TID, text item delimiters} to {text item delimiters, "Act 2 Up:"}
	set act2up to text item 2 of act2upfull
	set text item delimiters to TID
	
else if p contains "Act 2 Down:" then
	
	set act2downfull to p
	set {TID, text item delimiters} to {text item delimiters, "Act 2 Down:"}
	set act2down to text item 2 of act2downfull
	set text item delimiters to TID
	
end if
end repeat

display alert "Your Running Times for the performance of: " & showname & return message "Act 1 Up: " & tab & tab & act1up & return & "Act 1 Down: " & tab & act1down & return & "Act 2 Up: " & tab & tab & act2up & return & "Act 2 Down: " & tab & act2down & return & return & "Act 1 Running Time of: " & tab & "THIS NEEDS A RUNNING TIME" & return & "Act 2 Running Time of: " & tab & "THIS NEEDS A RUNNING TIME" buttons {"Ok"} default button 1

 

 

Can anyone help a fellow DSM out with a section of code that would work out 2 running times? One for act 1 and one for act 2?

 

Many thanks in advance,

Chris

Link to comment
Share on other sites

I would approach this in a different

 

- create a new cue list within qlab, and in this place 5 blank note cues, numbered 1 to 5

cue 1 then is house open

cue 2 is act 1 up

cue 3 is act 1 down

cue 4 is act 2 up

cue 5 is act 2 down

 

- at each relevant point in the show replace the text in that blank cue with the dateTime for that point (include the date, see below for why)

 

- at the end you would then convert each string back into a dateTime (which I think may have been what you were missing before) applescript only likes times, not dates - so you would say something like "set act1start to the date [get the cue 1 value]"

 

- this then allows you to subtract one from the other - giving you the result in seconds, which you can then divide by 60 to get the hours

 

Hope that makes sense!

Link to comment
Share on other sites

Hi guys,

 

I see where your coming from however it would be nice to have it save to a file also to ensure all show timings are backed up aswell for when I am not on book.

 

How does applescript deal with time and not so well date?

 

There isn't much info online on how to find the difference in times.

 

Thanks,

Chris

Link to comment
Share on other sites

There isn't much info online on how to find the difference in times.

 

Dont now apple script but in other languages you need to set a varible to each of the diffrent times,as the actual time is changing all the time,something like act1uptime=actualtime, rest of code...act1downtime=actualtime Then act1runtime=act1downtime-act1uptime

Link to comment
Share on other sites

Hi Themadhippy,

 

The issue with that is the the applescript doesn't keep running as it is all within separate cues within qlab, unless there is some way to keep it running from the first cue?

 

Im just thinking it cant be that difficult surely to take 1 time away from the other when I have them at present in 2 text string variables. Im thinking it should just be a case of converting them from a text variable to a time variable and then subtracting surely? No?

 

Thanks,

Chris

Link to comment
Share on other sites

when I have them at present in 2 text string variables. Im thinking it should just be a case of converting them from a text variable to a time variable and

you normally have to convert the text string into a number varible or integer variable then carry out any maths,no idea what the magic spell is for applescript,but often you also have to point to the correct bit of the text varible to convert

ETA

also make sure all the variables have there own unique name

Link to comment
Share on other sites

Hey guys!,

 

You were correct. I had to convert to time of date from string and I managed to find a snippet of code elsewhere and butchered it.

 

For anyone looking for it this is what helped me out!

 


set act1uptimesecs to time of date (act1up as string)
set act1downtimesecs to time of date (act1down as string)
set act2uptimesecs to time of date (act2up as string)
set act2downtimesecs to time of date (act2down as string)

set Act1DurationSecs to act1downtimesecs - act1uptimesecs
set Act2DurationSecs to act2downtimesecs - act2uptimesecs

set theHoursA1 to (Act1DurationSecs div hours)
set theMinutesA1 to ((Act1DurationSecs div minutes) - theHoursA1 * 60)
set theRemainderSecondsA1 to (Act1DurationSecs mod minutes)

set theHoursA2 to (Act2DurationSecs div hours)
set theMinutesA2 to ((Act2DurationSecs div minutes) - theHoursA2 * 60)
set theRemainderSecondsA2 to (Act2DurationSecs mod minutes)

set act1duration to theHoursA1 & " hours " & theMinutesA1 & " minutes and " & theRemainderSecondsA1 & " Seconds" as text
set act2duration to theHoursA2 & " hours " & theMinutesA2 & " minutes and " & theRemainderSecondsA2 & " Seconds" as text

 

 

Cheers,

Chris

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.