スニペットをデバッグする

このページはDesktop Studio向けです。現在、CXone Studioはこのページで説明されているオプションをサポートしていません。

Snippet エディターウィンドウからスニペットをデバッグできます。デバッガを使用して、スニペットコード内の変数を確認できます。これはコードの問題を解決するのに役立ちます。スニペットのデバッグには5つのオプションがあります。

また、コードに動的オブジェクトや配列が含まれている場合は、それらの内容を表示してその変化を確認できます。

スニペットの構文をチェックする

Studioでスニペット内の構文をチェックできます。

  1. Studioで、Snippetアクションを含むスクリプトを開きます。
  2. Snippetアクションをダブルクリックします。
  3. Text View タブにコードがない場合、Snippetコードを追加します。
  4. Snippet エディターウィンドウの下部にあるCheck Syntaxアイコンをクリックします。

    構文エラーがない場合、構文チェックアイコンの横にあるステータスフィールドにOkayというメッセージが表示されます。

    構文エラーが見つかった場合は、エラーを説明するメッセージがポップアップ表示されます。この説明には、エラーのある行番号が含まれています。さらに、構文チェックアイコンの隣のステータスフィールドに、Error at line [#]というメッセージが表示されます。

  5. 見つかった構文の問題をすべて修正します。
  6. スニペットコード内の行を1つ以上選択し、Comment out selected linesアイコンをクリックできます。これは、エラーをスキップして残りのエラーをチェックする場合に便利です。
  7. スニペットコード内のコメントアウトされた行を1つ以上選択し、Uncomment the selected linesアイコンをクリックすることができます。

デバッガツールを使用する

  1. Studioで、Snippetアクションを含むスクリプトを開きます。
  2. 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.

ブレークポイントを使ってデバッグする

スニペットコードの特定の行でデバッグを停止したい場合は、ブレークポイントを設定できます。これにより、スニペットを1行ずつステップスルーすることなく、スニペットの途中で変数や値を確認できます。

  1. Studioで、Snippetアクションを含むスクリプトを開きます。
  2. 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.

スニペットコードをステップスルーする

デバッガツールを使用して、スニペットコードを1行ずつステップスルーすることができます。これにより、各行が実行されるたびに変数とその値がどのように変化するかを確認できます。

  1. Studioで、Snippetアクションを含むスクリプトを開きます。
  2. 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.

動的オブジェクトと配列の内容を表示する

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.

TRACEを使ってデバッグする

TRACE キーワードを使用すると、ロギングを使用してデバッグできます。このキーワードは、Snippet エディターウィンドウでデバッガツールを使用する場合にのみ機能します。このキーワードをスニペットコードに含めてデバッガーを実行すると、Snippet エディターウィンドウの下部に表示されるTrace ペインにテキストが出力されます。

TRACE キーワードは、Snippet エディターウィンドウの外では無視されます。これはデバッガツールでのみ機能します。

構文は次のとおりです:TRACE "<text>"

二重引用符内のテキストはSnippet エディターウィンドウに出力されます。これはウィンドウ下部のTrace ペインに表示されます。

変数の値を出力するには、二重引用符内で変数代入を使用します。たとえば。

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

この例の出力は次のようになります。

I = 1

I = 2

I = 3

I = 4

I = 5