Satimage Previous | Next
Testing a script
Home Documentation Smile AppleScript terminals Using AppleScript in Smile Testing  
To debug a script in Smile, you have to work in an AppleScript terminal.
  • If you want to debug a compiled script or an applet, open it in Smile (it will open in a colored Script window), then copy the script, or the relevant extract, into a new AppleScript terminal (use File ▸ New AppleScript terminal ⌘N).
  • The interpreter lets you run whatever line or block of lines. Run whatever lines are required to initialize your variables, then step in your script. Whenever needed, you can skip some instructions or step back in the script.
  • To inspect the content of a variable, select any occurrence of the variable's name in the script and ⌘R: its content will print to the Console.
  • To assign a new value to a variable on the fly, run such a line as below in any AppleScript terminal.
    set my_variable to some_value
  • To use a handler in the interpreter, you must first compile the handler so that it be included in the context: select it and press ⌘R.
    If the handler uses a variable which is defined outside itself, such as a property of your script, the variable must explicitly be declared as a global variable in the handler. For instance if you have once defined the_root_folder and your handler uses that variable, the handler should include the declaration below.
    global the_root_folder
    In the compiled script, the declaration is optional provided the variable is declared as a property of the script.
If you attempt to run as a single line the first line of a if structure, of a repeat structure, or of a tell structure, you will trigger an error: you must take specific steps to debug those structures, as explained below.
See also below short instructions about debugging a handler.
Version française
Copyright ©2008 Paris, Satimage