#SRC: JCON

#  test image(), serial(), *x, and explicit conversion functions

record point(x,y)
record circle(x, y, r)

procedure main(args)
   local c1, c2, c3, c4, s

   dump()
   dump(047)
   dump(3.14159)
   dump('7121')
   dump("asparagus")
   dump(main)
   dump(write)
   dump(args)
   dump([])
   dump([1,2,3,4,5])
   dump(set())
   dump(insert(insert(insert(set(),1),2),3))
   dump(table())
   dump(insert(table(), 3, 4))
   dump(point)
   dump(circle)
   dump(point(0))
   dump(circle(0))
   dump(point(1,2))
   dump(point(3,4,5))
   dump(circle(6,7))
   dump(circle(4,5,6))

   c1 := create 10 to 19
   c2 := create 20 to 29
   c3 := create 30 to 39
   every 1 to 7 do @c2 & @c3
   c4 := ^c3
   every 1 to 7 do @c2 & @c3
   dump(c1)
   dump(c2)
   dump(c3)
   dump(c4)

   write()
   write("          x     integer(x)      real(x)   numeric(x)",
   	"    string(x)      cset(x)")
   every convert(0 | 0.0 | "0" | '0' | 7 | 7.315 | "7.315" | '7.315' | 
   	"25e-2" | "25e-1" | " 4e+3 " | " 3.8e3  " |
   	"" | " " | " -3 " | "  9  " | " +77" | "  4.7  ")

   s := &cset[1:140] || &cset[250:256]
   write()
   write(image(s))
   write()
   write(image(cset(s)))
   write()

end


procedure dump(x)
   local n

   if n := serial(x) then
      writes("#", n, "  ", "*", *x)
   else if type(x) === ("string" | "cset" | "real" | "integer") then
      writes("    *", *x)
   write("\t", type(x), " : ", image(x))
   return
end


procedure convert(x)
   write(pad(x), pad(integer(x) | &null), pad(real(x) | &null),
      pad(numeric(x) | &null), pad(string(x) | &null), pad(cset(x) | &null))
   return
end


procedure pad(x)
   return right(image(\x) | "---", 13)
end
