Path: 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 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