ILE C/C++ Programmer's Guide


Changing the Value of a Variable

You can change variables by using the EVAL debug command with assignment. To specify the scope of the EVAL command, use a QUAL command.

Example:

This example shows you how to use the EVAL debug command to assign an expression to a variable.

  1. Enter DSPMODSRCr. The Display Module Source display is shown.
  2. Enter display module T1520IC2.
  3. To specify the scope of the EVAL command you can use a QUAL command. For example, QUAL 48. will qualify the EVAL command to the scope that line 48 is located at. Line 48 is the number within the function to which you want the variables scoped for the following EVAL debug command.
    Note:
    You do not always have to use the QUAL debug command before the EVAL debug command. An automatic QUAL is done when a breakpoint is encountered or a step is done. This establishes the default for the scoping rules to be the current stop location.
  4. To change an expression in the module shown enter: EVAL x=<expr>, where x is the variable name and <expra> is the expression you want to assign to variable x.

    For example, "EVAL hold_formatted_cost [1] = '#'" changes the array element at 1 from $ to # and shows "hold_formatted_cost[1]= '#' = '#':" on the Display Module Source display as shown:

    +--------------------------------------------------------------------------------+
    |                              Display Module Source                             |
    |                                                                                |
    | Program:   T1520PG1       Library:   MYLIB          Module:   T1520IC2         |
    |     47      if (j<0) return(0);                                                |
    |     48      if (hold_formatted_cost[i] == '$')                                 |
    |     49      {                                                                  |
    |     50        formatted_cost[j] = hold_formatted_cost[i];                      |
    |     51        break;                                                           |
    |     52      }                                                                  |
    |     53      if (i<16 &&; !((i-2)%3))                                           |
    |     54      {                                                                  |
    |     55        formatted_cost[j] = ',';                                         |
    |     56        --j;                                                             |
    |     57      }                                                                  |
    |     58      formatted_cost[j] = hold_formatted_cost[i];                        |
    |     59      --j;                                                               |
    |     60    }                                                                    |
    |     61                                                                         |
    |                                                                                |
    | Debug . . .  ___________________________________________________________       |
    | ________________________________________________________________________       |
    | F3=End program   F6=Add/Clear breakpoint   F10=Step   F11=Display variable     |
    | F12=Resume       F17=Watch variable   F18=Work with watch F24=More keys        |
    | hold_formatted_cost[1]= '#' = '#'                                              |
    +--------------------------------------------------------------------------------+


[ Top of Page | Previous Page | Next Page | Table of Contents ]