
function octalstr(sys ii, optional nd) as string
================================================
if ii=0 and nd=0 then return "0"
int b,j,n,p,v
string bi
b=ii
n=nd
if n=0 then n=11*Sizeof(sys)/4
p=n
bi=space n
for j=n to 1 step -1
  v=b and 7
  mid bi,j,chr v+48
  if v then p=j
  shr b,3
next
if nd=0
  return mid bi,p 'trim leading zeros
else
  return bi
end if
end function


print OctalStr 42
print OctalStr 42,4
