Consdier the following package

   exportedFunction::usage = "...";
      globalVariable = Null;
      initializePackage[args___] := (globalVariable = workOn1[args]);
      exportedFunction[args___] := 
            If[globalVariable===Null, Abort[]];
            localVariable = workOn2[globalVariable, args];
      workOn1[args___] := ...;
      workOn2[gv_, args___] := ...;
      workOn3[lv_] := ...;

and assume that is being debugged in a workbench session, and that a break point has been set somewhere in exportedFunction. The debugger reports on the values of localVariable, but I can never see the value of globalVariable. Is there a way to inspect the value of globalVariable as well?

  • $\begingroup$ closely related: Inspecting non-variable state from a breakpoint in Workbench $\endgroup$
    – WReach
    Commented Mar 26, 2014 at 13:17
  • $\begingroup$ @WReach: I think, though I might be wrong, that this post is not closely related to the example you linked. In the exapmpel that you are pointing to the variable (a) is local. I am asking specifically about global variables. Did I missunderstood something? $\endgroup$
    – zorank
    Commented Mar 31, 2014 at 18:36
  • $\begingroup$ OK, I've added an answer to explain more fully. $\endgroup$
    – WReach
    Commented Apr 1, 2014 at 13:42

1 Answer 1


The Workbench's Expressions debugging view allows to evaluate any arbitrary expression, including global variables. While stopped at a breakpoint, press the Create a new watch expression button in the Expressions view and enter the name of the global variable as the expression. If the Expressions view is not visible, you can open it from the Workbench main menu using Window / Show View... / Expressions.

In contrast, if one wants to inspect a local variable x one must use the watch expression VariableValue[x].

We are not limited to referencing global and local variables. Any expression can be watched (see Inspecting non-variable state from a breakpoint in Workbench for a screenshot).

  • $\begingroup$ I understand finally! I tried it though, and could not make it work. The expression (a global private variable in the package) never evaluates. Do I have to reference with the full name (including the context)? $\endgroup$
    – zorank
    Commented Apr 4, 2014 at 15:36
  • 1
    $\begingroup$ @zorank Yes, a private variable would need to be fully qualified. For example, packageName`Private`globalVariable (from the question). $\endgroup$
    – WReach
    Commented Apr 5, 2014 at 2:57
  • $\begingroup$ Domo arigato! It works! Just tested it. $\endgroup$
    – zorank
    Commented Apr 7, 2014 at 9:19

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.