Path: utzoo!utgpu!news-server.csri.toronto.edu!rpi!think.com!spool.mu.edu!mips!swrinde!elroy.jpl.nasa.gov!decwrl!adobe!heaven!heaven.woodside.ca.us From: glenn@heaven.woodside.ca.us (Glenn Reid) Newsgroups: comp.sys.next Subject: Re: postscript question (dictionary stack) Message-ID: <527@heaven.woodside.ca.us> Date: 13 Jun 91 05:58:17 GMT Article-I.D.: heaven.527 References: <9106120942.AA01457@nextasy2.eecs.wsu.edu> Sender: glenn@heaven.woodside.ca.us Lines: 52 David Watola writes > > > here's one for the postscript gurus: > > the fall 1990 next software and peripherals catalog, page 229, shows > that displaytalk has a dictionary stack browser. the browser column on the > right shows the dictionary stack with a list of dictionaries... > > is there an easy way of doing this? how is it possible to find the names > of all the dictionaries on the dictionary stack. i can think of one way, but > it is such a horrible brute force method that i wouldn't dare code it. > i have looked through the adobe red (well, orange and white) book to no avail. > have i missed something simple? No, you haven't missed anything. The only way to get the "name" of a dictionary on the dictionary stack is to use brute force, and that might not even work. A dictionary doesn't have to have a name in order to be on the dictionary stack, and for that matter, it can have any number of names, because a "name" in this sense is just another dictionary entry that has a dictionary as its value. Consider the following bits of code, all of which will confound attempts to list the "names" of dictionaries on the dictstack: % example one 100 dict begin % example two /name1 40 dict def /name2 name1 def /name3 name1 def name1 begin % example three 20 dict dup { 10 pop } exch def begin I don't know what DisplayTalk does if it can't find the name, but it probably gets lucky most of the time, because people most often give names to dictionaries. The only way to find these names is to do a "forall" on all of the dictionaries you can find and compare the values to the dictionary that you're interested in. Brute force, to say the least, and if you try to recursively examine other dictionaries you find during your "forall", you run the risk of getting into an infinite loop. But it sure is handy when it does tell you something :-) -- Glenn Reid RightBrain Software glenn@heaven.woodside.ca.us NeXT/PostScript developers ..{adobe,next}!heaven!glenn 415-326-2974 (NeXTfax 326-2977)