Article View: comp.lang.postscript
Article #7773Re: Printing dictionary names
From: Geof Cooper
Date: Fri, 30 Dec 1988 21:36
Date: Fri, 30 Dec 1988 21:36
45 lines
1579 bytes
1579 bytes
The only way to get the "name" of a dictionary (it may have
more than one, or different names in different contexts) is
to scan all dictionaries on the dict stack and do an associative
search for the name. Here is a procedure that I wrote to do
this some time ago. It uses the "dstack" variable from $error,
but can easily be modified to get the dict stack currently
in effect. As an efficiency hack, userdict and systemdict
are checked for as special cases. The outer two ifelse's
serve no other purpose.
- Geof
% print a dictionary by searching for it in the other dictionaries
% must be called with $error begun.
/pdict
{
dup systemdict eq
{ (-dictionary: systemdict\n) print pop }
{
dup userdict eq
{ (-dictionary: userdict\n) print pop }
{
print_dict begin
/toprint exch def
/found false def
dstack length 1 sub -1 0
{
dstack exch get
{
toprint eq
{ (-dictionary: ) print
=string cvs print (\n) print
/found true def
exit
}
{ pop }
ifelse
} forall
found { exit } if
} for
found not { (-dictionary-\n) print } if
end
} ifelse
} ifelse
} def
Technical Details
Message-ID:
<2854@imagen.UUCP>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!bloom-beacon!bu-cs!purdue!decwrl!sun!imagen!daemonShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!bloom-beacon!bu-cs!purdue!decwrl!sun!imagen!daemon From: geof@apolling (Geof Cooper) Newsgroups: comp.lang.postscript Subject: Re: Printing dictionary names Message-ID: <2854@imagen.UUCP> Date: 30 Dec 88 21:36:07 GMT Sender: daemon@imagen.UUCP Lines: 45