^O
Interpret a string as an octal number
WSupported on Windows
|
USupported on Unix
|
VSupported on OpenVMS
|
NSupported in Synergy .NET
|
octal = ^O(expression[, size])
Return value
octal
The integer value of an alpha expression, evaluated as an octal number. If expression is null, the result is 0. (i)
Arguments
expression
The alpha expression to interpret as octal. (a)
size
(optional) A value that specifies the size of the resulting integer. Valid values are
1 = The result is returned in an i1 value.
2 = The result is returned in an i2 value.
4 = The result is returned in an i4 value.
8 = The result is returned in an i8 value.
Discussion
If expression does not contain only valid octal digits (0 through 7), an “Octal digits expected in argument (string)” error ($ERR_ODIGXP) is generated.
By default, ^O produces an i4 value if the return value fits in 32 bits or an i8 value if the return value is larger than 32 bits. If size is specified, the value is returned in an integer of that size. If the value exceeds the specified size, it is truncated to fit. When used as the initial value of an automatically sized integer field, the field size is determined by the magnitude of the ^O result, not the size returned by ^O .
An ^O value that fits in 32 bits but has the high bit set will be negative. If you want a positive value when a negative i4 would normally be returned, specify a value of 8 in the optional size argument.
Examples
The following example uses alpha input as data for an octal arithmetic computation. Note that if the alpha variable contains any nonnumeric data other than a blank, a decimal point, or a sign (+ or –), a “Bad digit encountered” error ($ERR_DIGIT) is generated.
subroutine math a_avar ,a record val1 ,d5 val2 ,d5 result ,d10 proc result = (val1*val2) / ^o(a_avar) . . . xreturn endsubroutine