%OCT

Return an octal string representation of a numeric value

WTSupported in traditional Synergy on Windows
WNSupported in Synergy .NET on Windows
USupported on UNIX
VSupported on OpenVMS
string = %OCT(value[, magnitude])

Return value

string

The octal string representation of value. (a)

Arguments

value

The value to convert to an octal character string. (n)

magnitude

(optional) A value that determines the number of characters in the returned string, as follows: (n)

1 = 3-character string for an 8-bit value

2 = 6-character string for a 16-bit value

4 = 11-character string for a 32-bit value

8 = 22-character string for a 64-bit value

Discussion

%OCT converts a decimal data value to a 32-bit longword value.

If magnitude is not present or if it contains a value other than 1, 2, 4, or 8, the resulting string is 11 characters long (if value can be represented in 32 bits) or 22 characters long (if value cannot be represented in 32 bits).

Examples

The following example builds and spawns a command string to check for the protection mode of a specific file. The protection modes are stored in a file named chkmod.txt.

function chk_mode 
     a_file             ,a 
.define MODCHN          ,18 
.define MODFIL          ,"WRK:chkmod.txt" 
record 
    string              ,a80 
    slen                ,d2 
    file                ,a30 
    modes               ,a9 
    value               ,d9 
    i                   ,i1 
 
proc 
    file = a_file 
    open(MODCHN, i, a_file) [err=nofile] ;Does file exist? 
    close MODCHN 
    xcall s_bld(string, slen, "ls -salt %A >%A", a_file, MODFIL)
    xcall spawn(string)                  ;Get full listing 
    clear string 
    file = MODFIL 
    open(MODCHN, i, MODFIL) [err=nofile] 
    reads(MODCHN, string, nofile) 
    modes = string(5:9)                  ;Get protection modes (check position!) 
    for i from 1 thru 9 
      value(i:1) = .not.(modes(i:1).eq.'-') 
    freturn %oct(value, 1) 
nofile, 
    writes(TTCHN, "Error: " + file + " not found") 
    freturn ("-1") 
endfunction