Article View: comp.lang.postscript
Article #8630Re: PostScript question (help needed)
From: Mike Tietel
Date: Thu, 21 Dec 1989 17:03
Date: Thu, 21 Dec 1989 17:03
101 lines
3448 bytes
3448 bytes
In article <314@vidiot.UUCP>, brown@vidiot.UUCP (Vidiot) writes:
>
> /$DITroff 140 dict def $DITroff begin
The above line is the key to the misunderstanding. The
"/$DITroff 140 dict def" creates a dictionary named "$DITroff"
with enough space for 140 key-value pairs. The "$DITroff begin"
just makes the dictionary "$DITroff" current (i.e., puts the
dictionary "$DITroff" on top of the dictstack). Placing the
dictionary on top of the dictstack allows you to place key-value
pairs in the dictionary using the "def" operator instead of the
"put" operator (i.e., "/hi (hello) def" instead of
"$DITroff /hi (hello) put").
> .
> many definitions created
> .
> end
The "end" pops the topmost dictionary off of the dictstack, note
however that this dictionary is still known by the name "$DITroff".
All that has been done up to this point is define a few key-value
pairs in the dictionary "$DITroff". NOTHING HAS BEEN THROWN AWAY!
The end does not cause this dictionary to be lost forever, because
the dictionary is known by the name "$DITroff"!!!
> Then a definition is created for ditstart that does another dictionary for
> $DITroff. This time there isn't an end, so far so good.
>
> /ditstart{$DITroff begin
The above line does not "do another dictionary" it makes the
"$DITroff" dictionary current so that some new key-value pairs
may be added to it.
> /nfonts 60 def % NFONTS makedev/ditroff dependent!
> ...
> }def
> .
> more dictionaries and macro definitions
> .
> ditstart
> (psc)xT
> 576 1 1 xr
> ...
> 1 f
> xi
> %%EndProlog
> %%Page: 1 1
> 10 s 0 xH 0 xS 1 f
> %body of PostScript pages goes here
> %%Trailer
> xt
> %This procedure does the end for the dictionary.
> xs
>
Note from the red book that:
dict - *creates* an *empty* dictionary and places it on the operand stack
begin - pushes a dictionary on the dictstack
end - pops a dictionary off the dictstack
If I write a program like the following:
2 dict begin
/hi (hello) def
/bye (goodbye) def
end
the dictionary created *is* lost forever.
However, if I write a program:
/mydict 2 dict def % create a dict called "mydict"
mydict begin
% define key-value pairs
/hi (hello) def
/bye (goodbye) def
end
the dictionary is not lost because we have named it "mydict".
We could also have written this program as follows:
/mydict 2 dict def % create a dict called "mydict"
mydict /hi (hello) put % define one key-value pair
mydict /bye (goodbye) put % define one key-value pair
or:
/mydict 2 dict def % create a dict called "mydict"
mydict begin /hi (hello) def % define one key-value pair
mydict begin /bye (goodbye) def % define one key-value pair
In all three cases "mydict" will contain the same key-value pairs.
If there are more questions, don't hesitate...
mjt
--
Mike Tietel
Northern Telecom, Inc. (612) 932-8017
9701 Data Park, H-200 mike@ntmtka.mn.org
Minnetonka, MN 55343 {rosevax,bungia}!ntmtka!mike
Technical Details
Message-ID:
<1967@ntmtka.mn.org>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!uwvax!umn-d-ub!umn-cs!nis!ntmtka!mikeReferences:
<314@vidiot.UUCP>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!uwm.edu!uwvax!umn-d-ub!umn-cs!nis!ntmtka!mike From: mike@ntmtka.mn.org (Mike Tietel) Newsgroups: comp.lang.postscript Subject: Re: PostScript question (help needed) Message-ID: <1967@ntmtka.mn.org> Date: 21 Dec 89 17:03:41 GMT References: <314@vidiot.UUCP> Organization: Northern Telecom Inc., Minnetonka, MN Lines: 101