Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Code copied from Bluebook and Greenbook barfs in GSview, why?

32 views
Skip to first unread message

Robert Baer

unread,
Mar 24, 2013, 8:23:51 PM3/24/13
to
I copied the last part of the complaint into the .PS file for
documentation.
**
%!
%% TRY3.PS COPIED FROM bluebook page 46
%%
%% GSview barfs:
%%
%% showpage
%%
%% --- End offending input ---
%% file offset = 0
%% gsapi_run_string_continue returns -101
%%
%%EndComments

/inch (72 mul) def % 72 pixels per inch

/wedge
{ newpath
0 0 moveto
1 0 translate
15 rotate
0 15 sin translate
0 0 15 sin -90 90 arc
closepath
} def

gsave
3.75 inch 7.25 inch translate
1 inch 1 inch scale
wedge 0.02 setlinewidth stroke
grestore

gsave
4.25 inch 4.25 inch translate
1.75 inch 1.75 inch scale
0.02 setlinewidth
1 1 12
{ 12 div setgray
gsave
wedge
gsave fill grestore
0 setgray stroke
grestore
30 rotate
} for
grestore

showpage

**
%!PS-Adobe-2.0
%%Title: patternfill.ps
%% TRY4.PS COPIED FROM greenbook page 138-143
%%
%% GSview barfs ..
%% begin FontDict /ctm get setmatrix
%%
%%
%% --- End offending input ---
%% file offset = 1129
%% gsapi_run_string_continue returns -101
%%
%%EndComments
%%BeginProcSet: patternfill 1.0 0
% width height matrix proc key cache
% definepattern -> font
/definepattern { %def
7 dict begin
/FontDict 9 dict def
FontDict begin
/cache exch def
/key exch def
/proc exch cvx def
/mtx exch matrix invertmatrix def
/height exch def
/width exch def
/ctm matrix currentmatrix def
/ptm matrix identmatrix def
/str
(12345678901234567890123456789012)
def
end
/FontBBox [ %def
0 0 FontDict /width get
FontDict /height get
] def
/FontMatrix FontDict /mtx get def
/Encoding StandardEncoding def
/FontType 3 def
/BuildChar { %def
pop begin
FontDict begin
width 0 cache { %ifelse
0 0 width height setcachedevice
}{ %else
setcharwidth
} ifelse
0 0 moveto width 0 lineto
width height lineto 0 height lineto
closepath clip newpath
gsave proc grestore
end end
} def
FontDict /key get currentdict definefont
end
} bind def
% dict patternpath -%
dict matrix patternpath -/
patternpath { %def
dup type /dicttype eq { %ifelse
begin FontDict /ctm get setmatrix
}{ %else
exch begin FontDict /ctm get setmatrix
concat
} ifelse
currentdict setfont
FontDict begin
FontMatrix concat
width 0 dtransform
round width div exch round width div exch
0 height dtransform
round height div exch
round height div exch
0 0 transform round exch round exch
ptm astore setmatrix
pathbbox
height div ceiling height mul 4 1 roll
width div ceiling width mul 4 1 roll
height div floor height mul 4 1 roll
width div floor width mul 4 1 roll
2 index sub height div ceiling cvi exch
3 index sub width div ceiling cvi exch
4 2 roll moveto
FontMatrix ptm invertmatrix pop
{ %repeat
gsave
ptm concat
dup str length idiv { %repeat
str show
} repeat
dup str length mod str exch
0 exch getinterval show
grestore
0 height rmoveto
} repeat
pop
end end
} bind def
% dict patternfill -%
dict matrix patternfill -/
patternfill { %def
gsave
clip patternpath
grestore
newpath
} bind def
% dict patterneofill -%
dict matrix patterneofill -/
patterneofill { %def
gsave
eoclip patternpath
grestore
newpath
} bind def
% dict patternstroke -%
dict matrix patternstroke -/
patternstroke { %def
gsave
strokepath clip patternpath
grestore
newpath
} bind def
% dict ax ay string patternashow -%
dict matrix ax ay string patternashow -/
patternashow { %def
(0) exch { %forall
2 copy 0 exch put pop dup
false charpath
currentpoint
5 index type /dicttype eq { %ifelse
5 index patternfill
}{ %else
6 index 6 index patternfill
} ifelse
moveto
3 copy pop rmoveto
} forall
pop pop pop
dup type /dicttype ne { pop } if pop
} bind def
% dict string patternshow -%
dict matrix string patternshow -/
patternshow { %def
0 exch 0 exch patternashow
} bind def
/opaquepatternfill { %def
gsave
1 setgray
fill
grestore
patternfill
} bind def
/square { %def
gsave
moveto
dup 0 rlineto
dup 0 exch rlineto
neg 0 rlineto
closepath
findfont % a pattern font
patternfill
grestore
} bind def
%%EndProcSet
%%EndProlog
%%BeginSetup
15 15 [300 72 div 0 0 300 72 div 0 0]
{ %definepattern
2 setlinecap
7.5 0 moveto 15 7.5 lineto
0 7.5 moveto 7.5 15 lineto
2 setlinewidth stroke
} bind
/RIGHTdiagonal true definepattern pop
15 15 [300 72 div 0 0 300 72 div 0 0]
{ %definepattern
2 setlinecap
7.5 0 moveto 0 7.5 lineto
15 7.5 moveto 7.5 15 lineto
2 setlinewidth stroke
} bind
/LEFTdiagonal true definepattern pop
30 30 [300 72 div 0 0 300 72 div 0 0]
{ %definepattern
2 2 scale
2 setlinecap
7.5 0 moveto 15 7.5 lineto
0 7.5 moveto 7.5 15 lineto
7.5 0 moveto 0 7.5 lineto
15 7.5 moveto 7.5 15 lineto
0.5 setlinewidth stroke
} bind
/crosshatch true definepattern pop
%%EndSetup
%%Page: 1 1
/RIGHTdiagonal 72 460 100 square
/LEFTdiagonal 72 480 120 square
/crosshatch 72 500 140 square
showpage
%%Trailer

**

Dan Coby

unread,
Mar 24, 2013, 10:19:54 PM3/24/13
to
On 3/24/2013 5:23 PM, Robert Baer wrote:
> I copied the last part of the complaint into the .PS file for documentation.
--snip--


You mangled the copying from the Blue and Green books.

There are a pair of asterisks at the end of each file that should not be there.
Delete them.

The second file has several mangled lines like:

% dict patternpath -%
dict matrix patternpath -/
patternpath { %def


These should be:

% dict patternpath -
% dict matrix patternpath -
/patternpath { %def

There are other examples of this sort of problem. Fix them.

With the problems corrected, the files run.


Dan

Robert Baer

unread,
Mar 28, 2013, 9:07:20 PM3/28/13
to
There were NO asterisks in either file, that was my way of indicating
them as separate.
On the second file, i found that there were a LOT of copy errors like
that; fixed them and all was well.
BUT
%!
% TRY3.PS COPIED FROM bluebook page 46
%
% GSview barfs:
%
% showpage
%
% --- End offending input ---
% file offset = 0
% gsapi_run_string_continue returns -101
%
%EndComments
% 72 pixels per inch

clear

/inch (72 mul) def

/wedge
{ newpath
0 0 moveto
1 0 translate
15 rotate
0 15 sin translate
0 0 15 sin -90 90 arc
closepath
} def

gsave
3.75 inch 7.25 inch

stack
==

translate
1 inch 1 inch scale
wedge 0.02 setlinewidth stroke
grestore

gsave
4.25 inch 4.25 inch translate
1.75 inch 1.75 inch scale
0.02 setlinewidth
1 1 12
{ 12 div setgray
gsave
wedge
gsave fill grestore
0 setgray stroke
grestore
30 rotate
} for
grestore

showpage
%%EOF


Errors from above seen:
Displaying non DSC file G:/PostScript Books/try3.ps
72 mul % "inch" as expected
7.25
72 mul
3.75
(72 mul) % but here it is,
"duplicated"..messing up the stack!
Error: /typecheck in --translate--
Operand stack:
3.75 (72 mul) 7.25 % "inch" missing..see above
Execution stack:
%interp_exit .runexec2 --nostringval-- --nostringval--
--nostringval-- 2 %stopped_push --nostringval-- --nostringval--
false 1 %stopped_push 1926 1 3 %oparray_pop 1925 1
3 %oparray_pop 1909 1 3 %oparray_pop 1803 1 3
%oparray_pop --nostringval-- %errorexec_pop .runexec2
--nostringval-- --nostringval-- --nostringval-- 2 %stopped_push
--nostringval--
Dictionary stack:
--dict:1176/1684(ro)(G)-- --dict:0/20(G)-- --dict:83/200(L)--
Current allocation mode is local
Last OS error: No such file or directory



luser- -droog

unread,
Mar 28, 2013, 10:57:18 PM3/28/13
to
Should be curly braces instead of parens. Parens just makes a string. Braces make a procedure.

luser- -droog

unread,
Mar 31, 2013, 2:47:28 AM3/31/13
to
On Thursday, March 28, 2013 9:57:18 PM UTC-5, luser- -droog wrote:
> On Thursday, March 28, 2013 7:07:00 PM UTC-5, Robert Baer wrote:
>
> > Dan Coby wrote:
>
> > /inch (72 mul) def
>
> Should be curly braces instead of parens. Parens just makes a string. Braces make a procedure.
>

/Or/ you could also add `cvx` to make it an executable string. Nominally less efficient, but a neat trick.

/inch (72 mul) cvx def % looks like a string, works like a procedure


--
looks like a pump
feels like a sneaker
0 new messages