Fragmentos de depuración

Puede depurar los snippets desde la ventana del editor Snippet . El depurador le permite ver las variables en el código de snippets. Esto puede ayudarlo a resolver problemas en su código. Hay cinco opciones para depurar snippets:

Además, si su código contiene matrices u objetos dinámicos, puede ver su contenido y como cambia.

Revisar la sintaxis del snippet

Puede solicitar que Studio compruebe la sintaxis de un snippet.

  1. En Studio, abra un script que contenga una acción Snippet.
  2. Haga doble clic en la acción Snippet.
  3. Agregue el código Snippet en la pestaña Text View , si aún no lo contiene.
  4. Haga clic en el Check Syntax ícono en la parte inferior de la ventana del editorSnippet .

    Si no se encuentran errores de sintaxis, el campo de estado junto al ícono de Revisar sintaxis muestra el mensaje Okay.

    Si se encuentran errores de sintaxis, aparece un mensaje de error que lo describe. La descripción incluye el número de línea donde se encuentra el error. Además, el campo de estado junto al ícono de Revisar sintaxis muestra el mensaje Error at line [#].

  5. Corrija cualquier problema de sintaxis que se haya encontrado.
  6. Puede seleccionar una o más líneas en el código del snippet y hacer clic en el Comment out selected lines icono . Esto es útil si desea omitir un error y verificar si hay errores restantes.
  7. Puede seleccionar una o más líneas comentadas en el código del snippet y hacer clic en el Uncomment the selected lines icono .

Utilice la Herramienta de depuración

  1. En Studio, abra un script que contenga una acción Snippet.
  2. Haga doble clic en la acción Snippet.
  3. Add Snippet code on the Text View tab, if it doesn't already contain some.
  4. On the right side of the Snippet editor window, click the Debugger tab.
  5. Click the down-arrow button on the right side of the Debug icon An icon of a window with a green right-facing triangle. On the right side of the icon is a down-facing black triangle that opens a drop-down menu. and select StartAn icon of a green play button triangle..
  6. If there are any syntax errors in the code, the Snippet editor window expands. All errors in the code appear in a pane at the bottom of the window. If there are no errors, skip to the next step.

    1. Correct the errors.
    2. When the errors have been corrected, click the Close or Clear Trace Output icons An X. to close the error pane.
    3. Start the debugger again.
  7. View the contents of the Variables as Text tab. The tab shows the variables and their values when all of the code has been executed if you didn't set a breakpoint.
  8. You can select one or more lines in the snippet code and click the Comment out selected lines icon An icon with open and closed angle brackets next to each other with a blue forward slash between them.. This is helpful if you want to remove some code to see how the outcome of the debugging changes.
  9. You can select one or more lines of commented-out code and click the Uncomment the selected lines icon An icon with open and closed angle brackets next to each other with a forward slash between them. A large red forward slash crosses the other characters. to add those lines back into the snippet.

Depurar con un punto de interrupción

Puede definir un punto de interrupción si desea que se detenga la depuración en una línea específica del código del snippet. Esto le permite ver las variables y los valores conforme avanza el snippet sin pasar por él línea por línea.

  1. En Studio, abra un script que contenga una acción Snippet.
  2. Haga doble clic en la acción Snippet.
  3. Add Snippet code on the Text View tab, if it doesn't already contain some.
  4. Click in the column to the left of the line numbers in the Snippet editor window. A red circle appears at that line number.

  5. On the right side of the Snippet editor window, click the Debugger tab.
  6. Click the down-arrow button on the right side of the Debug icon An icon of a window with a green right-facing triangle. On the right side of the icon is a down-facing black triangle that opens a drop-down menu. and select StartAn icon of a green play button triangle..
  7. If there are any syntax errors in the code, the Snippet editor window expands. All errors in the code appear in a pane at the bottom of the window. If there are no errors, skip to the next step.

    1. Correct the errors.
    2. When the errors have been corrected, click the Close or Clear Trace Output icons An X. to close the error pane.
    3. Start the debugger again.
  8. View the contents of the Variables as Text tab. The tab shows the variables and their values at the breakpoint, if you set one. The line where the debugging paused for the breakpoint is highlighted in the Snippet Editor window.
  9. If you're done with the breakpoint, click the red circle again to clear it.
  10. Set another breakpoint, if you need one.
  11. To continue debugging from the breakpoint, click the Resume icon An icon of a green play triangle..
  12. To stop debugging, click the Stop Debugging A black square. icon.

Paso a paso del Código de Snippets

Puede usar la herramienta de depuración para recorrer el fragmento de código línea por línea. Esto le permite ver cómo cambian las variables y sus valores a medida que se ejecuta cada línea.

  1. En Studio, abra un script que contenga una acción Snippet.
  2. Haga doble clic en la acción Snippet.
  3. Add Snippet code on the Text View tab, if it doesn't already contain some.
  4. On the right side of the Snippet editor window, click the Debugger tab.
  5. Click the down-arrow button on the right side of the Debug icon An icon of a window with a green right-facing triangle. On the right side of the icon is a down-facing black triangle that opens a drop-down menu. and select StartAn icon of a green play button triangle..
  6. If there are any syntax errors in the code, the Snippet editor window expands. All errors in the code appear in a pane at the bottom of the window. If there are no errors, skip to the next step.

    1. Correct the errors.
    2. When the errors have been corrected, click the Close or Clear Trace Output icons An X. to close the error pane.
    3. Start the debugger again.
  7. View the contents of the Variables as Text tab. It displays the variables in the code and their values when the snippet code starts.
  8. Click the Step icon An icon to move to the next line in the snippet.
  9. Repeat steps the preceding two steps for each line in the snippet.
  10. If you want to skip the remaining lines of code, click the Resume icon An icon of a green play button triangle.. The Variables as Text tab displays the variables and their values when all of the snippet code has executed.
  11. To stop debugging, click the Stop Debugging A black square. icon, then repeat this process starting from step 3.

Ver contenido de las Matrices y objetos dinámicos

You can view the contents of dynamic objects in the Snippet editor window when you run the debugger. This allows you to verify that the object holds the data it's supposed to at each step in your code.

  1. In Studio, double-click on a Snippet action.
  2. Add snippet code, if necessary.
  3. On the Debugger tab, click the Variables as Tree tab.
  4. On the Debugger tab, click the down arrow next to the Start Debugging icon An image of a triangular green play buttonand select Step Into A series of horizontal lines with an arrow pointing from one line to the one beneath it.. If you don't want to step through the code line by line, click the Start Debugging icon.
  5. Click the Step A series of horizontal lines with an arrow pointing from one line to the one beneath it. icon and observe the contents on the Variables as Tree tab. Each time you click Step, this field updates with the variables and objects in the script after the previous line of code. Skip this step if you clicked Start Debugging.
  6. When you have stepped through all lines of code or if you clicked Start Debugging, the Variables as Tree tab displays all variables, objects, and their contents at the end of the snippet.
  7. You can click the + icon next to any string arrays or dynamic objects in the code to expand them. If the content is another array or object, you can continue to expand the tree to see what each entity contains.

Depurar usando TRACE

La palabra claveTRACE  le permite depurar mediante el registro. Esta palabra clave solo funciona cuando se usa la herramienta de depuración en la ventana del editorSnippet . Cuando la incluya en el código de su snippet y ejecute el depurador, el texto se envía al Trace panel que aparece en la parte inferior de la ventana del Snippet editor.

Se ignora la TRACE palabra clave fuera de la ventana del Snippet editor. Únicamente funciona con la herramienta de depuración.

La sintaxis es: TRACE "<text>"

El texto entre comillas dobles se envía a la ventana del Snippet editor. Aparece en el Trace panel en la parte inferior de la ventana.

Puede usar la sustitución de variables entre las comillas dobles para imprimir el valor de las variables. Por ejemplo:

FOR i=1 TO 5
{
   TRACE "I = {i}"
}

La salida de este ejemplo es:

I = 1

I = 2

I = 3

I = 4

I = 5