[comp.lang.postscript] HELP! Bug in blue book ?

grantk@manta.NOSC.MIL (Kelly J. Grant) (02/03/90)

I'm not a serious hacker, but I have written
a pretty good amount of PostScript code....and
I swear I had three other people carefully look over
what I did.  I was using the Circular Text, program
10, page 167 of the blue book.  I checked every
single line against the book, but got nothing but
blank page.  My setup is such that I cannot watch
the program run or get error status.

Does anyone know if an errata list (sp?) exists
for the Adobe series ?

(Thanks) show

Kelly
grantk@manta.nosc.mil   (619)225-8401
-- 
Kelly Grant        grantk@manta.nosc.mil   (619) 225-8401
Computer Sciences Corp          ^^^^^^^^ Important: manta.UUCP won't get to me
4045 Hancock Street      "If you are given lemons.....see if you can trade for
San Diego, CA 92110       chocolate" - me

grantk@manta.NOSC.MIL (Kelly J. Grant) (02/03/90)

In article <1006@manta.NOSC.MIL>, grantk@manta.NOSC.MIL (Kelly J. Grant) writes:

I found the problem.  In the process of displaying the text, the 
'outsidecircletext' does a 'forall' loop through the input string.
It gets each character AS AN 'int' type in the body of the procedure!
It then must send each character to the procedure that actually
places the date on the page.  The lower procedure is expecting an
argument of type 'string', as it is doing some calculations followed
by a 'show' of the stack argument.  The bug is in the 'outsidecircletext'
line that follows:

   () dup 0 charcode put outsideplacechar

This is the effect of this line (as I understand it :-)

   A blank string is put on the stack
   It is duplicated
   'charcode' is 'put' at position 0 of the first string.

The problem is, 'put' doesn't leave anything on the stack!  The
originally blank string is modified, but this isn't saved into
anything, and is subsequently lost.  The only thing on the stack
after 'put' is the original blank string.

Here is my fix:

   /s 2 string def   %% possibly unnessary, but like I said, I'm not good 
   s 0 charcode put  %% don't understand why a 'def' isn't necessary here
   s outsideplacechar

It may just be dumb luck, but it works now.

Anyway, thanks for listening.  

Kelly


-- 
Kelly Grant        grantk@manta.nosc.mil   (619) 225-8401
Computer Sciences Corp          ^^^^^^^^ Important: manta.UUCP won't get to me
4045 Hancock Street      "If you are given lemons.....see if you can trade for
San Diego, CA 92110       chocolate" - me

jeynes@adobe.COM (Ross A. Jeynes) (02/03/90)

In article <1006@manta.NOSC.MIL> grantk@manta.NOSC.MIL (Kelly J. Grant) writes:
>what I did.  I was using the Circular Text, program
>10, page 167 of the blue book.  I checked every
>single line against the book, but got nothing but
>blank page.  My setup is such that I cannot watch

There is a pretty common mistake that people make when typing in this 
program.  Because the text is Helvetica (i.e. a proportional font), the 
following line is often mis-typed since the space character isn't as wide
as the other characters:

   () dup 0 charcode put outsideplacechar

should really be:

   ( ) dup 0 charcode put outsideplacechar
%  (^add space here)

There's another line further down in the program that needs to be changed
in a similar manner.  The reason this bombs is that the put operator is
trying to put a value into a string which has no storage associated with
it.

Good luck...


Ross Jeynes              
Developer Support                                   jeynes@adobe.com
Adobe Systems Incorporated                 {sun|decwrl}!adobe!jeynes

woody@rpp386.cactus.org (Woodrow Baker) (02/04/90)

In article <1006@manta.NOSC.MIL>, grantk@manta.NOSC.MIL (Kelly J. Grant) writes:
I have used that piece of code for years.    I think that the problem is
with the font used to set the blue book.  I had real fits with some of the
code there.  Specifically, there is a line that reads

()dup 0 charcode put....  OR SO IT SEEMS, when you look at it in the blue book.
It is realy

( ) dup 0 charcode put... NOTE, THERE IS A SPACE between the ()!  It is not
apparent in the blue book.

Cheers
Woody

> (Thanks) show
> 
> Kelly
> grantk@manta.nosc.mil   (619)225-8401
> -- 
> Kelly Grant        grantk@manta.nosc.mil   (619) 225-8401
> Computer Sciences Corp          ^^^^^^^^ Important: manta.UUCP won't get to me
> 4045 Hancock Street      "If you are given lemons.....see if you can trade for
> San Diego, CA 92110       chocolate" - me

kaz@nanovx.UUCP (Mike Kazmierczak) (02/06/90)

>In article <1006@manta.NOSC.MIL>, grantk@manta.NOSC.MIL (Kelly J. Grant) writes:
>The bug is in the 'outsidecircletext'
>line that follows:
>
>   () dup 0 charcode put outsideplacechar
 I found the same thing.  If one subsitutes ( ) instead of () then it works.
The space isn't real clear in the original text.

Mike Kazmierczak -- X Systems -- INTERNET: kaz%nanovx.UUCP@gatech.edu
UUCP: gatech!nanovx!kaz

cplai@daisy.UUCP (Chung-Pang Lai) (02/06/90)

In article <1006@manta.NOSC.MIL> grantk@manta.NOSC.MIL (Kelly J. Grant) writes:
>I'm not a serious hacker, but I have written
>a pretty good amount of PostScript code....and
>I swear I had three other people carefully look over
>what I did.  I was using the Circular Text, program
>10, page 167 of the blue book.  I checked every
>single line against the book, but got nothing but
>blank page.  

I remember this problem showed up in this newsgroup quite awhile back.
The error is in one of the space.  I believe it is () vs. ( ) that
causes the code to abort.  Try put in the space or take out the space,
I don't remember which.

Adobe was brain damaged to publish code listings in variable spaced font.

hascall@cs.iastate.edu (John Hascall) (02/06/90)

In article <1744@adobe.UUCP> jeynes@adobe.UUCP (Ross A. Jeynes) writes:
}In article <1006@manta.NOSC.MIL> grantk@manta.NOSC.MIL (Kelly J. Grant) writes:
}>what I did.  I was using the Circular Text,...
 
}There is a pretty common mistake that people make when typing in this 
}program.  Because the text is Helvetica (i.e. a proportional font), the 
}following line is often mis-typed since the space character isn't as wide
}as the other characters:
 
}   () dup 0 charcode put outsideplacechar
 
}should really be:
 
}   ( ) dup 0 charcode put outsideplacechar
}%  (^add space here)
 
    Ah yes, that one took my a while to find too....
    I pencilled (penciled?) in a ? in our copy to spare anyone else
    the trouble...

      (?) dup 0 charcode ....

     since it doesn't really matter what character you stick in there
     as it is only a placeholder (IMHO this is something the author
     should have done in the first place).

     Why do people use proportional fonts for programs in books and
     documentation!!!  In a "previous life" I worked for "User Services"
     and we always printed the examples/code in a fixed width font because
     there are a lot of people out there who get upset if they can't type
     it in EXACTLY like they see it.

John Hascall