Script for updating Text cues running slow

67 views
Skip to first unread message

Chris Devlin

unread,
Oct 14, 2025, 11:10:01 AMOct 14
to QLab
Hey Gang, I have made a script for the operator to input names that update text cues in multiple places (for geomotary reasons) but it runs rather slow when it's during a show. It does work but if theres a way I could improve the speed of it running (Mac Studio) it would make life a lot less stressful. Any tips on future code would be appreciated as Im still wrapping my head around AS.


Code:


tell application id "com.figure53.QLab.5" to tell front workspace
-- Prompt once for a comma-separated list of names
display dialog "Enter FOUR PLAYER NAMES, separated by commas [NO SPACE]:" default answer "" buttons {"OK"} default button "OK"
set userText to text returned of result

-- Split the input into a list
set AppleScript's text item delimiters to ","
set nameList to every text item of userText
set AppleScript's text item delimiters to ""

-- Loop through 4 names, assign to Group 1 ("Name1"–"Name4")
repeat with n from 1 to 4
set cueName to "Name" & n
set targetCue to (first cue whose q number is cueName)
set text of targetCue to item n of nameList
set text format of targetCue to {fontFamily:"Arial", fontStyle:"Bold", fontSize:100}
end repeat

-- Loop through same 4 names, assign to Group 2 ("Player1"–"Player4")
repeat with n from 1 to 4
set cueName to "Player" & n
set targetCue to (first cue whose q number is cueName)
set text of targetCue to item n of nameList
set text format of targetCue to {fontFamily:"Arial", fontStyle:"Bold", fontSize:100}
end repeat


-- Loop through same 4 names, assign to Group 2 ("Nameboard1"–"Nameboard4")
repeat with n from 1 to 4
set cueName to "Nameboard" & n
set targetCue to (first cue whose q number is cueName)
set text of targetCue to item n of nameList
set text format of targetCue to {fontFamily:"Arial", fontStyle:"Bold", fontSize:100}
end repeat






end tell

Rich Walsh

unread,
Oct 14, 2025, 4:02:30 PMOct 14
to ql...@googlegroups.com
This is all I can come up with to optimise this, but it shouldn’t make a huge difference for 24 operations…

tell application id "com.figure53.QLab.5" to tell front workspace

set userText to text returned of (display dialog "Enter FOUR PLAYER NAMES, separated by a space:" default answer "" buttons {"OK"} default button "OK")

set nameList to words of userText -- ### Assuming that since the original request was for no spaces, the names can be space-delimited rather than comma-delimited?

repeat with n from 1 to 4

set eachName to item n of nameList

set text of cue ("Name" & n) to eachName -- ### As q number MUST be unique you can address the cue directly rather than using the "first cue whose q number is" form

set text format of cue ("Name" & n) to {fontFamily:"Arial", fontStyle:"Bold", fontSize:100} -- ### Can this not be set ONCE AND FOR ALL before running this script, rather than every time?

set text of cue ("Player" & n) to eachName

set text format of cue ("Player" & n) to {fontFamily:"Arial", fontStyle:"Bold", fontSize:100} -- ### As above

set text of cue ("Nameboard" & n) to eachName

set text format of cue ("Nameboard" & n) to {fontFamily:"Arial", fontStyle:"Bold", fontSize:100} -- ### As above

end repeat

end tell


I don’t know if the “live text” property would be observably quicker to work with than “text”?

Today, I can’t find a single post that lists all the AppleScript resources we’ve discussed here, but you can search the group for “AppleScript Language Guide” and "AppleScript The Definitive Guide”, plus of course the QLab Cookbook, the online manual (eg: https://qlab.app/docs/v5/scripting/script-cues/), MacScripter, and just a plain Google search will reveal some GitHub repositories. My basic tip for speeding things up is “minimise the number of Apple events”, eg: if you can “get” multiple values at once use “X of cues whose Y is” rather than iterating through a list, and store things in variables if retrieving the information will generate another request to QLab for it.

Rich

--
Contact support anytime: sup...@figure53.com
User Group Code of Conduct: https://qlab.app/code-of-conduct/
 
Instagram: https://www.instagram.com/Figure53
TikTok: https://www.tiktok.com/@QLab.app
Bluesky: https://bsky.app/profile/qlab.app
---
You received this message because you are subscribed to the Google Groups "QLab" group.
To unsubscribe from this group and stop receiving emails from it, send an email to qlab+uns...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/qlab/2c5aaf52-f569-4152-a861-2ae59835bcden%40googlegroups.com.

Chris Devlin

unread,
Oct 15, 2025, 9:43:29 AMOct 15
to QLab
OMG this worked perfectly thanks so much Rich!

Paul

unread,
Oct 15, 2025, 2:04:11 PMOct 15
to QLab
Generally doing things in loops in scripting languages is quite slow. You have four loops in your code - you could combine these into one.  Use words of rather than text items of  means you can avoid changing the text item delimiter and if you reference the resulting list just once in the loop by making a string, that would also help slightly. For clarity I would separate out defining and setting the text formats. And you could move the set text format to {..} and set that in the cue or a Template because it doesn't seem to change. (?) If you want to set them in the script then you can do that outside the loop, with cues whose ..

Doing all this reduces the loop to 4 statements which should speed things up ...

-- set text of Text cues from user input

-- Assumes 3 sets of Text cues numbered name1 .. name4 etc

tell application id "com.figure53.QLab.5" to tell front workspace

-- text formats, defined here for clarity

set ceris to {red:1, green:0, blue:0.6, alpha:1}

set white to {red:1, green:1, blue:1, alpha:1}

set paleBlueGreen to {red:0.8, green:1, blue:1, alpha:1}

set nameFormat to {rgbaColor:paleBlueGreen, fontName:"Verdana", fontSize:36}

-- if the format never changes, you could do this once in a different script or cue Template

set playerFormat to {rbgaColor:paleBlueGreen, fontSize:100}

set playerFormat to {rgbaColor:ceris, fontName:"Verdana", fontSize:102}

set nameBoardFormat to {rgbaColor:white, fontSize:104}


-- apply text format; don't need a loop here, using the 'cues whose .. condition' 

set text format of cues whose q number begins with "name" to nameFormat

set text format of cues whose q number begins with "player" to playerFormat

set text format of cues whose q number begins with "nameboard" to nameBoardFormat

set namesList to words of text returned of (display dialog "Enter 4 Names" default answer "John Paul George Ringo" with title "Player Names")

repeat with n from 1 to 4

-- only reference the list once

set myname to item n of namesList

try

set text of cue ("name" & n) to myname

set text of cue ("player" & n) to myname

set text of cue ("nameboard" & n) to myname

-- fail silently if the cue/number doesn't exist

end try

end repeat

end tell



Actually, do you need 3 groups of Text cues?  This might not be relevant for your situation but you can output the same text to  from one Stage to several destinations by using Routes from different Regions. For example, in Settings - Video - Output Devices tab create/check your displays and then in Video Outputs - edit the stage and add new region with route then you can send your Text cues with the names to 3 destinations.

hope this helps
Reply all
Reply to author
Forward
0 new messages