Debug Printing

Q-SYS Control 101 Training : Scripting Basics

3 ) Simple Communication

15m 13s

4 ) Feature License Activation

4m 12s

5 ) Block Controller

19m 7s

7 ) Flow Control

34m 20s

8 ) Control 101 Conclusion

1m 42s

Lesson Description

Debug Printing 2m 55s

Gather feedback from your script using the Debug Print function.

Video Transcript

Debug Printing 2m 55s
0:08
Let’s talk about feedback – not audio feedback, and not the kind of feedback your boss gives you …
0:14
Shower more.
0:15
… but feedback from your script so you know it’s actually doing something.
0:18
Oftentimes, the “Print” command is your best way to do this.
0:22
If you type “print”, which you’ll note turns blue as it is a reserved command word, then you can enter
0:28
the information that you want to be returned to you within the parentheses. Anything that you print
0:33
will be returned in the Debug Output window for your reference.
0:37
Printing is a great way to see the results of your script. You can tell the script to add one plus one,
0:43
but if you don’t also tell it to print the response then you’ll never know it actually did it!
0:48
Later when we build functions, it would be fairly common to include a print command within your
0:53
function as a way to confirm the function was actually performed. If you place a print command at
0:59
the top of the function, then you’ll know that function was called by the presence of the command
1:04
string in your debug window.
1:06
When printing, you can use either single quotes or double-quotes to enter a literal string to be
1:13
printed. Both methods work the same.
1:16
Other times you may want to print a variable, or a string that comes in from a third-party device, or
1:24
maybe the value of a certain control. Any number of things could be included within the parentheses
1:29
of a print command to be returned in the Debug Output window.
1:34
In the Block Controller, you’ll find the print command in the System category. You’ll notice that it has
1:40
a text string block connected to it by default, letting you type in your message. Later when we talk
1:45
about string manipulation you’ll see how we can add different types of information here.
1:50
But for now, just type in the message you want to be printed, and if you jump over to the Lua tab,
1:56
you can see the now familiar Print command has been autogenerated in our code.
2:02
So – is there an equivalent to a Print window in the Control Components? No, not really. You could
2:09
hover your mouse over any control pin to find out what a control’s current string is, or you could
2:15
send a control to a Text Display to get feedback on what it’s doing, but there isn’t a good way to
2:22
combine or manipulate strings together using Control Components.
2:26
Similarly, the only debug you get with Control Components is the angry cloud over your head when
2:32
you haven’t wired something correctly and you can’t figure out how to fix it. So even in something as
2:37
simple as Debug Printing, we can begin to see the functional differences between the flexibility of
2:43
these three programming methods. Go ahead and check out the exercise on
2:47
Debug Printing in the Control Worksheet, and move on to the next video when you’re ready.