[<<Previous Entry]
[^^Up^^]
[Next Entry>>]
[Menu]
[About The Guide]
:=
Inline assign--binary (Assignment)
------------------------------------------------------------------------------
Syntax
<idVar> := <exp>
Type
All
Operands
<idVar> is a valid variable identifier of any storage class,
including a field variable. If <idVar> is not visible or does not
exist, a private variable is created and assigned the result of <exp>.
<exp> is the expression whose result is assigned to <idVar>.
Description
The inline assignment operator (:=) assigns values of any data type to
variables of any storage class. The operator evaluates <exp>, assigns
the resulting value to <idVar>, and returns the resulting value as the
return value of the operation. This latter behavior permits multiple
assignments such as idVar1 := idVar2 := value. Unlike the simple assign
operator (=), the inline assignment operator (:=) can be used anywhere
an expression or constant is allowed, including variable declaration
statements. With a variable declaration statement, assignment
initializes a variable. Note, however, you cannot declare an array and
initialize elements within the same program statement.
If the reference to <idVar> is ambiguous (i.e., not declared at compile
time and not explicitly qualified with an alias), <idVar> is always
assumed to be MEMVAR. At runtime, if no private or public variable
exists with the specified name, a private variable is created. You can
assign field variables with the := operator by declaring the field
variable name in a FIELD statement or referring to the field name
prefaced by the FIELD-> alias or the name of the work area.
Examples
. Several examples of inline assignment follow:
LOCAL nValue := 10
//
IF (dDate := (DATE() - 1000)) = CTOD("12/20/79")
//
? SQRT(nValue := (nValue ** 2))
//
cTransNo := cSortNo := (CustId + DTOC(DATE()))
. This last example performs multiple assignments using the
inline assignment operator as you would with the STORE command. When
:= is used in this way, the assignments are executed from right to
left. This feature is particularly useful when you need to store the
same value to many different fields, possibly in different database
files.
CustFile->CustId := TransFile-> ;
TransNo := (CustId + DTOC(DATE())
See Also:
++
--
= (assign)
= (compound)
STORE*
This page created by ng2html v1.05, the Norton guide to HTML conversion utility.
Written by Dave Pearson