Variable from AppleScript to Network cue

80 views
Skip to first unread message

inapago

unread,
Dec 2, 2025, 9:38:26 AM (12 days ago) Dec 2
to QLab
Hi, I'm trying to send a variable data from Qlab A, to Qlab B. In my Qlab A i have AppleScript that open a Numbers file that contains 3000 rows and 4 or 5 columns. Applescript in a cue show a dialog to user asking for a value to search. Applescript looks in column A of Numbers, then returns columns B, C and D values.

I'm searching a way to put this values "foundData" in a network cue (OSC) to send to another Qlab B on LAN.:

tell application "QLab"
tell front workspace
set ruta to notes of cue "RutaNumbers"
end tell
end tell

if ruta is "" then
display dialog "No se ha seleccionado ningún archivo. Ejecuta primero el cue 'Seleccionar archivo Numbers'."
return
end if

-- Abrir archivo en Numbers
tell application "Numbers"
set docRef to open ruta
end tell

-- Preguntar número de empleado
display dialog "Introduce el número de empleado:" default answer ""
set employeeNumber to text returned of result

set foundData to ""

tell application "Numbers"
tell docRef
tell sheet "Empleados"
tell table "Empleados"
set totalRows to count of rows

repeat with i from 1 to totalRows
set cellA to value of cell 1 of row i

if cellA is not missing value then
if (cellA as text) is employeeNumber then
set colB to value of cell 2 of row i
set colC to value of cell 3 of row i
set colD to value of cell 4 of row i
set colE to value of cell 5 of row i


set foundData to (colB as text) & " " & (colC as text) & " | " & (colD as text)
exit repeat
end if
end if

end repeat
end tell
end tell
end tell
end tell

if foundData is "" then
display dialog "No encontrado."
return
end if


Paul

unread,
Dec 6, 2025, 6:02:00 AM (8 days ago) Dec 6
to QLab
you can set the parameter values for a Network cue in a script cue with

set parameter values of networkCue to "/some/osc/message " & param1 & space & param2 & space & param3

You may need to put string parameters in "quotes"

When looking up values in a (Numbers) spreadsheet you need to be comparing the same type of values (string, float or integer), so you may have to convert the type of values. (and unfortunately with AppleScript 'as integer' does not convert to integer but actually rounds)
Here is a complete script which looks up values in spreadsheet and uses data from matching row to set the parameters for a Network cue. It uses a handler 'on findDataInSheet' to make the logic clearer. you don't need to check for missing value is you are looking for an actual value. This is a demo script; needs error handling added for production use.

-- find data in spreadsheet and use values in parameters to network cue

-- need to add error check for production use

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

-- get the value to look for from user

set defaultNum to 5

set myValue to text returned of (display dialog "value to look for " default answer defaultNum with title "Get data from spreadshet")

-- get the row from spreadsheet based on matching data in specified column with value

-- must compare same type of values; so convert string to integer using div 1 [note 'as integer' actually rounds]

set myValue to myValue div 1

set mycol to 1

set myRowData to my findDataInSheet(mycol, myValue)

if myRowData is false then

display dialog "not found"

return

end if

-- for debugging display the values returned from spreadsheet row

--display dialog (myRowData as text) with title "Debug spreadsheet row returned"

-- adjust the column numbers here as necessary

set {param1, param2, param3} to items 2 thru 4 of myRowData

-- make a Network cue and set the parameters of the OSC message from spreadsheet data

make type "Network"

set netCue to last item of (selected as list)

-- set the parameter values of network cue using data from spreasheet

set parameter values of netCue to "/some/osc/message " & param1 & space & param2 & space & param3

-- set the other parameters of the Network cue here

end tell


on findDataInSheet(colNum, myValue)

-- find the value in the first column and return the row

-- assumes the spreadsheet is alreaady open in Numbers

tell application "Numbers" to tell active sheet of front document to tell first table

repeat with rown from 2 to row count

set rowarray to (value of cells 1 thru 4 of row (rown)) as list

if item colNum of rowarray is myValue then

return rowarray

end if

end repeat

end tell

       return false

end findDataInSheet



inapago

unread,
Dec 8, 2025, 11:54:30 AM (6 days ago) Dec 8
to QLab
I solve it, assuming the Cue 4 is an OSC cue in Qlab A, and cue 2 is a text cue in Qlab B to put data in:

tell application "QLab"
tell front workspace
set theCue to cue "4"

-- Construimos el mensaje OSC
set mensaje to "/cue/2/text \"" & foundData & "\""

try
set custom message of theCue to mensaje
start theCue
on error errMsg
display dialog "Error escribiendo OSC Message: " & errMsg
end try
end tell
end tell
Reply all
Reply to author
Forward
0 new messages