Release 10.1A: OpenEdge Development:
Progress 4GL Handbook

> ## Grouping assignments with the ASSIGN statement

> If you are assigning two or more values in a row, it is significantly faster to assign them all in a single statement using the `ASSIGN` keyword. Even if the values being assigned have nothing to do with one another, it is faster to do it in a single statement, as in this example:

>     ASSIGN THIS-PROCEDURE:PRIVATE-DATA = STRING(OrderNum)
>             hSource = SOURCE-PROCEDURE
>             shipDate:BGCOLOR = dateColor(PromiseDate, ShipDate).

> Here the code is setting an attribute on a procedure handle, a variable, and a field attribute. Even though these are unrelated, it is still best to `ASSIGN` them together.

> If you are assigning multiple field values within a single record buffer, the `ASSIGN` statement can be even more important. Progress adjusts index entries and does other work as part of each statement. If you assign two fields that participate in the same index in two separate statements, the index block is rebuilt once after each statement—a much greater overhead than doing it in one statement. In fact, because Progress assigns index entries at the end of each statement, you might even cause a temporary (but fatal) unique index violation if you assign part of a composite key in one statement and the other part in another. Don’t ever do this.

> Because of the efficiency of an `ASSIGN` statement without multiple assignments, some Progress developers always use the `ASSIGN` keyword even when the statement only does one assignment. There is no advantage to this. That is, these two statements are comparably fast:

>     Variable-a = Variable-b + 1.
>     ASSIGN Variable-a = Variable-b + 1.

Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095