|

...where show_window is a Boolean value. If true, the debug window is displayed, if false, the window is hidden. For example:


-- show the debug window Debug.ShowWindow(true);


If you call this script, the debug window will appear on top of your application, but nothing else will really happen. That's where the following Debug actions come in.


Debug.Print

This action prints the text of your choosing in the debug window. For example, try the following script:


Debug.ShowWindow(true);


for i = 1, 10 do

Debug.Print("i = " .. i .. "\r\n");

end


The "\r\n" part is actually two escape sequences that are being used to start a new line. (This is technically called a "carriage return/linefeed" pair.) You can use \r\n in the debug window whenever you want to insert a new line.


The above script will produce the following output in the debug window:


image


You can use this method to print all kinds of information to the debug window. Some typical uses are to print the contents of a variable so you can see what it contains at run time, or to print your own debug messages like "inside outer for loop" or "foo() function started." Such messages form a trail like bread crumbs that you can trace in order to understand what's happening behind the


scenes in your project. They can be invaluable when trying to debug your scripts or test your latest algorithm.


Debug.SetTraceMode

AutoPlay Media Studio can run in a special "trace" mode at run time that will print information about every line of script that gets executed to the debug window, including the value of Application.GetLastError() if the line involves calling a built-in action. You can turn this trace mode on or off by using the Debug.SetTraceMode action:


Debug.SetTraceMode(turn_on);


|