1. ASCII/numeric print
Art Adamson suggested making a form of ? (print) that
would display numbers the same way that the trace screen
does - with ASCII characters shown in color.
include graphics.e
procedure cprint(object x)
-- display an object with colored ASCII characters
if atom(x) then
printf(1, "%g", x)
if integer(x) and x >= 32 and x <= 127 then
text_color(BRIGHT_MAGENTA)
if x = 32 then
puts(1, 254) -- block character
else
puts(1, x)
end if
text_color(WHITE)
end if
else
-- sequence
puts(1, "{")
for i = 1 to length(x) do
cprint(x[i])
if i < length(x) then
puts(1, ',')
end if
end for
puts(1, "}")
end if
end procedure
cprint(65)
puts(1, '\n')
cprint(999.9)
puts(1, '\n')
cprint({1, 32, 42, 52 ,97, 155.5})
puts(1, '\n')
cprint("Euphoria")
puts(1, '\n')
You could add a procedure that calls cprint(),
then does puts(1, '\n'). You can't just add it to cprint() itself
because of it's recursive nature.
Regards,
Rob Craig
Rapid Deployment Software
2. Re: ASCII/numeric print
------ =_NextPart_000_01BD6A0A.F71C82E0
It's good to find that Robert finally has *finally* got some time to write code
in Euphoria for a change.
-- David Cuny
------ =_NextPart_000_01BD6A0A.F71C82E0