...where turn_on is a Boolean value that tells the program whether to turn the trace mode on or off.
Here is an example:
Debug.ShowWindow(true); Debug.SetTraceMode(true);
for i = 1, 3 do
Dialog.Message("Number", i);
end
File.Copy("C:\\fake_file.ext", "C:\\fake_file.bak");
Running that script will produce the following output in the debug window:
Notice that every line produced by the trace mode starts with "TRACE:" This is so you can tell them apart from any lines you send to the debug window with Debug.Print. The number after the "TRACE:" part is the line number that is currently being executed in the script.
Turning trace mode on is something that you will not likely want to do in your final, distributable application, but it can really help find problems during development. In fact, there is an option in the AutoPlay Media Studio build preferences that allows you to automatically turn on trace mode
every time you preview. (Choose Tools > Preferences and click on the Build category. In the Preview section, turn on the option called "Show Debug Window.") However, even with this option enabled, trace mode will not be turned on in the version that gets built when you publish your project, unless you specifically turn it on in your script.
Debug.GetEventContext
This action is used to get a descriptive string about the event that is currently being executed. This can be useful if you define a function in one place but call it somewhere else, and you want to be able to tell where the function is being called from at any given time. For example, if you execute this script from a button's On Click event on Page1:
Dialog.Message("Event Context", Debug.GetEventContext());
...you will see something like this:
Dialog.Message
This brings us to good ole' Dialog.Message. You have seen this action used throughout this document, and for good reason. This is a great action to use throughout your code when you are trying to track down a problem.
F i n a l T h o u g h t s
Final Thoughts
Hopefully this document has helped you to understand scripting in AutoPlay Media Studio. Once you get the hang of it, it is a really fun, powerful way to get things done.
O t h er Re s ou rce s
Here is a list of other places that you can go for help with scripting in AutoPlay Media Studio.
Help File
The AutoPlay Media Studio help file is packed with good reference material for all of the actions and events supported by AutoPlay Media Studio, and for the design environment itself. You can access the help file at any time by choosing Help > AutoPlay Media Studio Help from the menu.
Another useful tip: if you are in the script editor and you want to learn more about an action, simply click on the action and hit the F1 key on your keyboard.
User's Guide
The user's guide is a fantastic way to get started with AutoPlay Media Studio. It is written in an easy-to-follow tutorial format, teaching you about events, actions and scripts. You'll be off and
running in no time! The user's guide is part of the help file, which can also be accessed by choosing Help > AutoPlay Media Studio User's Guide from the menu.
AutoPlay Media Studio Web Site
The AutoPlay Media Studio Web site is located at http://www.indigorose.com. Be sure to check out the user forums where you can read questions and answers by fellow users and Indigo Rose staff as well as ask questions of your own.
A quick way to access the online forums is to choose Help > User Forums from the menu.
Indigo Rose Technical Support
If you need help with any scripting concepts or have a mental block to push through, feel free to visit http://www.indigorose.com for available support options. Although we can't write scripts for you or debug your specific scripts, we will be happy to answer any general scripting questions that you have.
The Lua Web Site
AutoPlay's scripting engine is based on a popular scripting language called Lua. Lua is designed and implemented by a team at Tecgraf, the Computer Graphics Technology Group of PUC-Rio (the Pontifical Catholic University of Rio de Janeiro in Brazil). You can learn more about Lua and its history at the official Lua web site:
This is also where you can find the latest documentation on the Lua language, along with tutorials and a really friendly community of Lua developers.
Note that there may be other built-in functions that exist in Lua and in AutoPlay Media Studio that are not officially supported in AutoPlay. These functions, if any, are documented in the Lua
5.1 Reference Manual.
Only the functions listed in the online help are supported by Indigo Rose Software. Any other "undocumented" functions that you may find in the Lua documentation are not supported. Although these functions may work, you must use them entirely on your own.