1. cprint(), Print(), PrintStr(), and PrintNum()
>Thanks, Terry. You have a nice improvement. I will use it. Maybe you should
>post it to the group so others can use it too. Bye, Art
>
>At 08:37 AM 7/1/98 -0500, Terry Constant wrote:
>Arthur Adamson wrote:
>>
>> The following cprint.e was supplied by R Craig. It permits the color
>> printing of any sequence. By commenting out portions of it, you can show
>> either the characters or the integers or both...not automatic choice in
>> trace however. I use it a lot and it may help you survive. Good luck. Art
>>
>Hi Art,
>
>Thanks for cprint. I made the following alterations that are useful to
>me, I thought you might be interested. I now just use Print(),
>PrintStr(), and PrintNum() that are defined after the altered cprint().
>
In accordance with Art's suggestion above, I am putting these routines on the
list. I hope they are useful to some.
Terry
--begin
include graphics.e
global procedure cprint(object x, string DispFlags)
--/ display an object with colored ASCII characters
integer
DispStr,
DispNum,
DispBoth
if length(DispFlags) = 0 then
DispBoth = True
else
DispBoth = False
end if
if DispBoth then
DispStr = True
DispNum = True
else
DispStr = find('S',upper(DispFlags)) > 0
DispNum = find('N',upper(DispFlags)) > 0
DispBoth = DispStr and DispNum
end if
if atom(x) then
if DispNum then
printf(1, "%g", x) --comment out if no integers desired
end if
if integer(x) and x >= 32 and x <= 127 then
if DispStr 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
end if
else
-- sequence
puts(1, "{")
for i = 1 to length(x) do
cprint(x[i],DispFlags)
if i < length(x) then
if DispNum 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 PrintNum(object o)
cprint(o,"n")
puts(1,"\n")
end procedure --PrintNum
--end
Terry Constant
constant at flash.net