Chapter Contents

Previous

Next
Command Directory

assign

Assign a Value to an Expression

ABBREVIATION
a{ssign}

FORMATS
Format 1: assign SCALAR-TYPE-EXPRESSION = VALUE
Format 2: assign AGGREGATE-TYPE-EXPRESSION = 1 {VALUE-LIST}| AGGREGATE-TYPE-EXPRESSION

DESCRIPTION
The assign command assigns the value (or values) specified by VALUE, VALUE-LIST, or AGGREGATE-TYPE-EXPRESSION to the expression identified by SCALAR-TYPE-EXPRESSION or AGGREGATE-TYPE-EXPRESSION. In both formats, the equal sign is required.

Format 1: Format 1 assigns a value, specified by VALUE, to the arithmetic, pointer, or bit-field object identified by SCALAR-TYPE-EXPRESSION. The SCALAR-TYPE- EXPRESSION argument is an expression whose type is arithmetic, pointer, or bit-field.

VALUE is an expression whose type is one of the following:

See Debugger Variables for details on argument types that are used with the assign command. If the VALUE argument and the SCALAR argument have different types, a conversion is made according to the SAS/C Compiler's rules for conversions.

You can assign a value to any expression of scalar type visible at the point where you issue the assign command.

Format 2: Format 2 assigns the source values on the right side of the assignment operator (=), specified by VALUE-LIST or AGGREGATE-TYPE-EXPRESSION, to a target aggregate identified by AGGREGATE-TYPE-EXPRESSION on the left side of the assignment operator.

The AGGREGATE-TYPE-EXPRESSION arguments can be an expression of type structure or union, provided that both source and target are declared with the same tag in the same compilation. (AGGREGATE-TYPE-EXPRESSION cannot be an array; use the copy command with arrays.)

The VALUE-LIST argument can also be used to assign values to the target AGGREGATE-TYPE-EXPRESSION. Any of the items in a VALUE-LIST can be a structure or union. If a union is specified, VALUE-LIST must contain exactly one item that is assigned to the first member of the union. For example, in the following statement, 5 is assigned to the first member of some_union :

assign some_union = { 5 }

To assign a value (for example, 9) to the second member of some_union , use assign as follows:

assign some_union.member2 = 9

The AGGREGATE-TYPE-EXPRESSION argument can be a structure with members that are aggregates.

The VALUE-LIST argument contains any or all of the following items, enclosed by braces:

Rules for assigning VALUE-LISTs to aggregate objects:

One of the elements of the aggregate can be an aggregate, in which case, the rules above apply (recursively) to that element. Therefore, if a member of a structure is a structure, the debugger expects to find a VALUE-LIST nested in another VALUE-LIST. For example, consider the following structure:

   struct a {
            int b;
            struct ccc d;
            long e;
            };

The structure needs a VALUE-LIST, as follows, with the values to be assigned to struct ccc d in the inside set of braces:

{b-value, {d-value, d-value, d-value, . . .}, e-value}

EXAMPLES
The assign examples in this section are based on the following declarations and #define statement:
   #define B_MAX 9

   int ival;
   char *p;
   struct XXX int a; short b,c;d;

The semantics in the examples are the same as for the assignment statement. In other words, assign i=5 does the same as i=5; in C.

assign ival = 3+B_MAX
assigns 12 to ival.

assign p = &ival
assigns the address of ival to a pointer object (scalar).

assign ival = 20
assigns a constant to an arithmetic object (scalar).

assign d = {1,2}
assigns values from a value list to a structure d (d.a=1,d.b=2) .

assign d = {1,ival,3}
assigns values from a value list to a structure d (d.a=1,d.b=20,d.c=3).

assign d = {d.b}
assigns d.b (a short) to the first element of structure d (d.a =20).

SYSTEM DEPENDENCIES
none

COMMAND CAN BE ISSUED FROM

PROFILE no
configuration file no
Source window prefix none

SCOPE
The assign command uses command scope to resolve references to all identifiers.

RETURN CODES SET
Successful: 0
Unsuccessful: 1

SEE ALSO


Chapter Contents

Previous

Next

Top of Page

Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.