Targetting a Cue by q number from a script

1,262 views
Skip to first unread message

Richard Bell

unread,
Mar 12, 2014, 11:12:18 AM3/12/14
to ql...@googlegroups.com
Hi All,

I'm just beginning to play with scripting within QLab and have, of course, been referring to the wealth of scripts available through the Figure 53 wiki but I'm having a little trouble with something.

I'm trying to write a script that creates a Start cue and Fade cue that both target another cue (by q number within the same workspace). I'm able to target the cue correctly by selecting it and using 'last item of selected' to reference the cue but ideally I'd like to take a user input using a 'display dialog' box and reference the cue using the q number. Is this possible?
I've tried variations on 'set q number of userTarget to userCueNo' and I get an error telling me "Can't set name of cue to \"testCue\" " or "Can't get cue "testCue" (where testCue is the q number of the cue I wish to target).

Below is the script in it's current development state (code has been heavily borrowed from scripts on the wiki):

set userDuration to 5

set userCueNo to text

set userCueNo to text returned of (display dialog "Please enter the cue number/name to target" default answer "" with title "Start and Fade in target cue" buttons {"Cancel", "OK"} default button 2)

set userTarget to cue

set q number of userTarget to userCueNo --as cue


--set userTarget to cue

--set userTarget to userCueNo


tell front workspace

    --set currentCue to last item of (selected as list)

    make type "Start"

    -- set newCueStart to selected last item of (selected as list)

    set mySel to selected

    set newCueStart to last item of mySel

    set cue target of newCueStart to userTarget

    --set playback position of current cue list to last item of selectedCues


    --make type "Fade"

    --set newCueFade to last item of (selected as list)

    --set cue target of newCueFade to userTarget

    --set duration of newCueFade to userDuration

    --newCueFade setLevel row 0 column 0 db -40

end tell




I hope that makes sense. I'd be grateful for any suggestions or help.

Many thanks,
Richard

Rich Walsh

unread,
Mar 12, 2014, 12:08:27 PM3/12/14
to ql...@googlegroups.com
Quickly, without analysing your code at length, the syntax would be:

set cue target of cue qNumberOfCueWhoseTargetYouWishToSet to cue qNumberOfCueYouWishToTarget

"set q number" will change the q number of a cue…

Rich

--
--
Change your preferences or unsubscribe here:
http://groups.google.com/group/qlab
 
Follow Figure 53 on Twitter: http://twitter.com/Figure53

---
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.
For more options, visit https://groups.google.com/d/optout.

Stephen Swift

unread,
Mar 12, 2014, 10:02:56 PM3/12/14
to ql...@googlegroups.com
On Wed, Mar 12, 2014 at 9:08 AM, Rich Walsh <rich...@mac.com> wrote:
> Quickly, without analysing your code at length, the syntax would be:
>
> set cue target of cue qNumberOfCueWhoseTargetYouWishToSet to cue
> qNumberOfCueYouWishToTarget

FWIW, There's a difference between cue 5 and cue "5"

I found that out a few weeks ago looking at Nick's script. It confused
me for a bit, until I realized:
* cue 5 is a reference to an internal pointer (I think the 5th cue I
created sequentially),
* and cue "5" references a cue in my workspace that I have assigned
its Number as "5".

This is intended behavior, correct? I haven't seen this documented anywhere.

If you are curious, download this workspace:

https://dl.dropboxusercontent.com/u/73933/cue_numbers.cues

and run the last two script cues, and watch the target value of cue "30"

Rich Walsh

unread,
Mar 13, 2014, 4:09:35 AM3/13/14
to ql...@googlegroups.com
It is as documented as anything in AppleScript if you read the sdef:

q number (text) : The number of the cue. Unique if present.

This tells you that you need to present a string if you want to use q number as a cue specifier.

"tell front workspace to get cue 5" is really interpreted as "tell front workspace to get cue 5 of its cues", ie: positional reference 5 in the list of cues in the workspace. It is a function of the current order of cues, not the order in which they were created: that would be uniqueID. It's all completely consistent with the underlying language structure of AppleScript, which is documented here:

https://developer.apple.com/library/mac/documentation/applescript/conceptual/applescriptlangguide/introduction/ASLR_intro.html

Rich

Andy Lang

unread,
Mar 13, 2014, 10:23:20 AM3/13/14
to ql...@googlegroups.com

On Thu, Mar 13, 2014 at 4:09 AM, Rich Walsh <rich...@mac.com> wrote:
This tells you that you need to present a string if you want to use q number as a cue specifier.

The reason for this, for those curious, is that q number is only really a number in name. You can just as easily letter your cues, or have a combination of letters and numbers; QLab won't force you to use numbers there. So it has to be a string to allow for that.

-Andy
Figure 53 Support

Richard Bell

unread,
Mar 14, 2014, 1:54:57 PM3/14/14
to ql...@googlegroups.com
Thanks all for your replies. I'm afraid I confused my original question slightly, as Rich pointed out, by referring to q number when I meant cue target. Anyway I tried the syntax Rich gave me but I'm still getting a (slightly different) error. Below is the barebones version of the script I'm trying and the error it's throwing:

set userCueNo to string

   
set userCueNo to text returned of (display dialog "Please enter the cue number/name to target" default answer "" with title "Start and Fade in target cue" buttons {"Cancel", "OK"} default button 2)
   
tell front workspace
       
    make type "Start"
    set newCueStart to last item of (selected as list)
    set cue target of cue newCueStart to cue userCueNo
    --set cue target of newCueStart to cue "testCue"
   
end tell

error "QLab got an error: Can’t make cue id \"74\" of workspace \"richard script sandbox\" into type integer." number -1700 from cue id "74" of workspace "richard script sandbox" to integer

The commented out line which targets "testCue" works but using the variable userCueNo in it's place throws the above error. I'm afraid I'm a little confused about the 'integer' the error is referring to. Again, any pointers will be gratefully received.

Many thanks,
Richard
Richard Bell
email: richard...@gmail.com
web: www.argyllrb.co.uk

Rich Walsh

unread,
Mar 15, 2014, 5:31:39 AM3/15/14
to ql...@googlegroups.com
On 14 Mar 2014, at 17:54, Richard Bell <richard...@gmail.com> wrote:

Thanks all for your replies. I'm afraid I confused my original question slightly, as Rich pointed out, by referring to q number when I meant cue target. Anyway I tried the syntax Rich gave me but I'm still getting a (slightly different) error. Below is the barebones version of the script I'm trying and the error it's throwing:

set userCueNo to string
   
set userCueNo to text returned of (display dialog "Please enter the cue number/name to target" default answer "" with title "Start and Fade in target cue" buttons {"Cancel", "OK"} default button 2)
   
tell front workspace
       
    make type "Start"
    set newCueStart to last item of (selected as list)
    set cue target of cue newCueStart to cue userCueNo
    --set cue target of newCueStart to cue "testCue"

newCueStart is a cue, not a string – so "set cue target of cue newCueStart to cue userCueNo" should read "set cue target of newCueStart to cue userCueNo". It is always best to troubleshoot in AppleScript Editor; then you would have seen something like this, which would have set alarm bells ringing:

set cue target of cue (cue id "42" of workspace "Untitled Workspace") of workspace 1 to cue "67" of workspace 1

The resulting error message ("Can’t make «class aCue» id \"42\" of «class qDoc» \"Untitled Workspace\" into type integer.") tells you that the script can't convert "«class aCue» id \"42\" of «class qDoc» \"Untitled Workspace\"" into an integer, which it is trying to do in order to present it as a number in the form "cue X".

Also, you don't need to declare userCueNo as a string as the class of a variable is set (and can also be changed) when you set the variable to a value.

Rich

Richard Bell

unread,
Mar 15, 2014, 6:35:02 AM3/15/14
to ql...@googlegroups.com
Thank you Rich! Again, a daft error I should have spotted. Thank you for talking it through.

Many thanks,
Richard
Richard Bell
mobile: +44 (0)7759 263006
email: richard...@gmail.com
web: www.argyllrb.co.uk

Stephen Swift

unread,
Mar 18, 2014, 11:36:55 AM3/18/14
to ql...@googlegroups.com
On Thu, Mar 13, 2014 at 1:09 AM, Rich Walsh <rich...@mac.com> wrote:
> It is as documented as anything in AppleScript if you read the sdef:
>
> q number (text) : The number of the cue. Unique if present.
>
> This tells you that you need to present a string if you want to use q number as a cue specifier.

Thanks for the explanation Rich.

I think where I'm not making the connection, is how can I tell cue "4"
is using the q number property in the dictionary? For example, for the
cue element:

cue n : A cue.

What does the n stand for? I always assumed it was a number.

tell front workspace

set blah to cue target of cue "2"

end tell


In this test, cue target has no Q number, and the result is a cue id
reference. Now this seems to be a reference to the order in which cues
were inserted, as I can move the cue around, delete another cue, add a
cue, and the cue id stays the same.

Another simple gotcha: I had "Use smart quotes and dashes" checked in
the Keyboard > Text System Preferences. The curly quotes would cause
compile errors in the QLab Script Editor. Feature Request: is it
possible for QLab to ignore that settings in its Script Editor (and
mimic the AppleScript editor behavior)?

Stephen

Rich Walsh

unread,
Mar 18, 2014, 11:53:00 AM3/18/14
to ql...@googlegroups.com
The "n" is italicised: it means it's a noun (cf: "make", a verb).

Cue ids are unique per cue and do not change. Cue N of workspace is position N in cues of workspace, so depends on cue order. If you are trying to use the form "cue q number" then you need to know what class the property q number is. It's text. This only works because "name" compiles as "q number" and can therefore be used as an object specifier. It saves you having to use "first cue whose q number is X". "cue named X" works too.

Rich
Reply all
Reply to author
Forward
0 new messages