1. cprint(), Print(), etc
I finished fleshing out my altered cprint() routines
so that they are more useful when debugging. Perhaps
they will be useful to others on the list.
--begin
include graphics.e
global procedure cprint(object x, string DispFlags)
--/ display an object with colored ASCII characters
--/ Display flags: s(tr) display strings, BRIGHT_MAGENTA
--/ d(ec) display numbers as decimal, BRIGHT_CYAN
--/ h(ex) display numbers as hexadecimal, BRIGHT_WHITE
integer
DispDec,
DispHex,
DispStr
-- default is to display strings and numbers as hex
DispStr = True
DispHex = True
DispDec = False
if length(DispFlags) > 0 then
DispStr = find('S',upper(DispFlags)) > 0
DispDec = find('D',upper(DispFlags)) > 0
DispHex = find('H',upper(DispFlags)) > 0
end if
if atom(x) then
if DispHex then
text_color(BRIGHT_WHITE)
printf(1, "%02x", x)
text_color(WHITE)
end if
if DispDec then
text_color(BRIGHT_CYAN)
printf(1, "%d", x)
text_color(WHITE)
end if
if integer(x) and x >= 1 and x <= 127 then
if DispStr then
if x = 7 then x = 173
elsif x = 9 then x = 175
elsif x = 10 then x = 174
end if
text_color(BRIGHT_MAGENTA)
puts(1, x)
text_color(WHITE)
end if
end if
else
puts(1, "{")
for i = 1 to length(x) do
cprint(x[i],DispFlags)
if i < length(x) then
if DispHex or DispDec then
puts(1, ',')
end if
end if
end for
puts(1, "}")
end if
end procedure
global procedure Print(object o)
cprint(o,"")
puts(1,"\n")
end procedure --Print
global procedure PrintStr(object o)
cprint(o,"s")
puts(1,"\n")
end procedure --PrintStr
global procedure PrintHex(object o)
cprint(o,"h")
puts(1,"\n")
end procedure --PrintNum
global procedure PrintDec(object o)
cprint(o,"d")
puts(1,"\n")
end procedure --PrintNum
global procedure PrintDecStr(object o)
cprint(o,"ds")
puts(1,"\n")
end procedure --PrintNum
global procedure PrintAll(object o)
cprint(o,"shd")
puts(1,"\n")
end procedure --PrintNum
--end
Terry Constant
mailto:constant at flash.net
http://flash.net/~constant