Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

I am getting the following error from gsview: Unrecoverable error: dictstackunderflow in end

New Here ,
Dec 23, 2010 Dec 23, 2010

In respnce to the following programming statement:

/cirtextdict 16 dict def

cirtextdict begin

     /findhalfangle

          {stringwidth pop 2 div

          2 radius mul pi mul div 360 mul

}def

This is straight out of the Bluebook. I am obviously new to ps programming, so what am I missing here?

TOPICS
Programming
1.4K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Dec 23, 2010 Dec 23, 2010

Wiz,

I'm at home right now so I can't check your typing with what's in the blue book.

It looks like a section/snippet of the example to set type on a circular/arcing baseline...?

Years ago, I used the same code with a few modifications to fix the sawtooth effect that they challenged us to fix for practice.

I'm not familiar with gsview (ghostscript?), but I would recommend using Adobe distiller for error reporting while you are learning the language.

If you supply your complete code (pardon me if you did) including the parameters then I could give you a more concise answer,

however I do have a couple of off-the-cuff observations:

1.) "cirtextdict" make sure that is consistently spelled throughout your program - I thought it was circtextdict in the blue book, but I haven't looked lately.

2.) If you are calling the "cirtextdict" dictionary multiple times then you need to have a corresponding end to match each begin in your program but I don't see you ending the cirtextdict dictionary in what you posted.

3.) The error would suggest that your program is trying to end a dictionary that wasn't begun, ergo the "dictstackunderflow in end".

4.) for the examples, if you continue to get tripped up on dictionary issues and you don't have alot of procedures to deal with and they have unique names then you can skip the dictionaries altogether and just let userdict (default) hold all the procedures in your program so you can concentrate on them instead.

Let us know how you are doing.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 26, 2010 Dec 26, 2010

Mr. Horton

 

Thank you for the timely response.

 

You are correct, "cirtextdict" is misspelled, but this is because the forum

interface apparently does not allow copy and I was forced to retype

the snippet which is where the typo came in.

 

If it were possible to have entered the whole program without retyping the whole

thing I would have done that.

 

The dict problem was occurring because of a misplaced def for pi at the

beginning.

 

The code I am using is adapted from a book titled "Learning Postscript - A

Visual Approach", PeachpitPress.

 

At any rate here is the present error msg:

 

Displaying non DSC file D:/AppDocs/PS/CrackedCircleLbl.ps

Loading NimbusRomNo9L-Medi font from %rom%Resource/Font/NimbusRomNo9L-Medi...

2590896 1273884 3162792 1864210 2 done.

Error: /undefined in outsidecircletext

Operand stack:

   (Cracked Recording Studios)   16   90   60

Execution stack:

   %interp_exit   .runexec2   nostringval   nostringval  

nostringval   2   %stopped_push   nostringval   nostringval  

false   1   %stopped_push   1910   1   3   %oparray_pop   1909   1   3  

%oparray_pop   1893   1   3   %oparray_pop   1787   1   3   %oparray_pop  

nostringval   %errorexec_pop   .runexec2   nostringval  

nostringval   nostringval   2   %stopped_push   nostringval

Dictionary stack:

   dict:1163/1684(ro)(G)   dict:0/20(G)   dict:83/200(L)

Current allocation mode is local

Last OS error: No such file or directory

--- Begin offending input ---

deplacechar**

    }forall

  grestore

 end

}def

 

    • I note here the error msg is only displaying a portion of the precedure name.

 

And here is the complete code listing in it's present form:

 

/font {findfont exch scalefont setfont} bind def

 

/circtextdict 16 dict def

circtextdict begin

 /findhalfangle

  {stringwidth pop 2 div

  2 xradius mul pi mul div 360 mul

}def

/outsidecircletext

 {circtextdict begin

 /radius exch def

 /centerangle exch def

 /ptsize exch def

 /str exch def

 /xradius radius ptsize 4 div add def

 gsave

  centerangle str findhalfangle add rotate

 str

  {/charcode exch def

  ( ) dup 0 charcode put outsideplacechar

  }forall

 grestore

 end

}def

/outsideplacechar

 {/char exch def

 /halfangle char findhalfangle def

 gsave

  halfangle neg rotate

  radius 0 translate

  -90

  char stringwidth pop 2 div neg 0 moveto

  char show

 grestore

 halfangle 2 mul neg rotate

}def

/insidecircletext

 {circtextdict begin

  /radius exch def /centerangle exch def

  /ptsize exch def /str exch def

  /xradius radius ptsize 3 div sub def

  gsave

   centerangle str findhalfangle sub rotate

   str

    {/charcode exch def

    ( ) dup 0 charcode put insideplacechar

    }forall

  grestore

 end

}def

/insideplacechar

 {/char exch def

 /halfangle char findhalfangle def

 gsave

  halfangle rotate

  radius 0 translate

  90 rotate

  char stringwidth pop 2 div neg 0 moveto

  char show

 grestore

 halfangle 2 mul rotate

 }def

 

 /pi 3.1415923 def

end

306 396 translate

2 2 scale

0 0 140 0 360 arc fill

1 setgray

0 0 119 0 360 arc fill

16/Times-Bold font

(Cracked Recording Studios)

16 90 60 outsidecircletext

14/Times-Bold font

(Professor's Picks - Vol I)

16 90 60 insidecircletext

 

Thank you for you for your generosity in this matter and I realize I may be

asking to much in expecting any more of your time.

 

 Wiz

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Dec 27, 2010 Dec 27, 2010

Wiz,

I'd be happy to help you solve the problem you are experiencing as you learn the PostScript language.

The chance of a typo is too great for me to accurately and quickly determine what your next step should be in correcting the code.

Can't you attach the code as a text file to your next post so that I can debug exactly what you are working with?

Cut and paste also works for me... not sure why it doesn't work for you.

There are a couple of things I saw in your code that don't make sense to me, but again, it may be the result of typos on your post and not in your working code.

1.)     In your outsideplacechar procedure the following code appears to be missing the rotate command after the "-90".

          "-90 char stringwidth pop 2 div neg 0 moveto char show"

          The rotate command will remove the -90 from the operand stack after rotating about the current position.

2.)     It appears that the code is defining a dictionary, then placing it on top of the dict stack, then storing procedures in it, that in turn, place

          the same dictionary on the dict stack again and then off again each time they are called. Unfortunately, unless the dictionary is on the dict stack the

          procedures in it can't be called. If you remove the dictionary begin and end that surround your individual procedures, along with fixing item 1

          above, then the code will distill/display.

3.)     When the section of code begins that actually draws something, the default setgray value is 0 (black).

          The code changes the origin (0, 0) to be in the middle of an 8-1/2 x 11 inch page.

          Then the scaling is changed to 200% (proportionately), a circle is drawn and filled with black.

          Next the setgray value is changed to 1 (white).

          A smaller circle is drawn concentric to the first and filled with white.

         

4.)      I expect that you are missing the code to change the setgray value to 1 (black) before attempting to set the two text strings.

5.)      Lastly, based on the results after making corrections I have suggested, The insidecircletext procedure appears to need to rotate by 180 degrees and

          possibly the radius needs to be increased, if both text strings are to appear as though they are set in the same "band" of a circle.

          Not having seen what the end result is supposed to look like I can only guess and so the code I pasted below doesn't reflect a change in radius.

Altered PostScript code:

%%PS

/font {findfont exch scalefont setfont} bind def

/circtextdict 16 dict def

/findhalfangle {stringwidth pop 2 div 2 xradius mul pi mul div 360 mul}def

/outsidecircletext  {
circtextdict begin
/radius exch def
  /centerangle exch def
  /ptsize exch def
  /str exch def
  /xradius radius ptsize 4 div add def
  gsave
   centerangle str findhalfangle add rotate
  str {
  /charcode exch def
  ( ) dup 0 charcode put outsideplacechar
   }forall
grestore
end
}def

/outsideplacechar {
/char exch def
  /halfangle char findhalfangle def
  gsave
   halfangle neg rotate
   radius 0 translate
   -90 rotate char stringwidth pop 2 div neg 0 moveto char show
  grestore
  halfangle 2 mul neg rotate
}def

/insidecircletext {
circtextdict begin
/radius exch def
/centerangle exch def
   /ptsize exch def
/str exch def
/xradius radius ptsize 3 div sub def
gsave
180 rotate
centerangle str findhalfangle sub rotate
str {
  /charcode exch def
      ( ) dup 0 charcode put insideplacechar

}forall
grestore
end
}def

/insideplacechar {
/char exch def
/halfangle char findhalfangle def
gsave
halfangle rotate
radius 0 translate
90 rotate char stringwidth pop 2 div neg 0 moveto char show
grestore
halfangle 2 mul rotate
}def

/pi 3.1415923 def

306 396 translate
2 2 scale
0 0 140 0 360 arc fill
1 setgray
0 0 119 0 360 arc fill
0 setgray
16

/Times-Bold font
(Cracked Recording Studios)
16 90 60 outsidecircletext
14

/Times-Bold font
(Professor's Picks - Vol I)
16 90 60 insidecircletext
showpage

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 30, 2010 Dec 30, 2010

Mr. Horton

Sorry for the delayed response but I recently upgraded to Win 7 and experienced

some difficulty getting my scanner/software working in the new environment.

 

Wiz

The subject line is probably redundant because I assume you worked on it in your

environment until you had it working. Just out of curiosity, what is your

working environment?

 

Still, after my frustration and those confounded error messages, it was a bit of

magic to plug your code in and bingo there was output. I especially want to

thank you for your commentary. This combined with being able to compare my

non-working code with yours has provided me with a valuable learning aid. I just

wish some of my instructors had been of your caliber.

 

I OCR scanned the page from the book I referred to with the relevant code per

your request.

 

I have included two additional attachments:

 

2. Is the intended output of the book's code. This will explain the setgray

confusion.

 

3. Requires an explanation of my project. I have a DVD which is intended as a

present (obviously I have missed the ship date) and this is intended as the

background for my disk label. To achieve this effect I placed a throwaway disk

in a microwave oven for 4 seconds and then directly scanned this disk.

 

Since the exact size of the black "donut" wasn't yet determined I left the text

placement - to be determined. On the other hand white text on a white

background could prove to be problematic.  

 

Again thank you. I really appreciate your help.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
Dec 30, 2010 Dec 30, 2010

Wiz,

On an HP HDX Premium Series laptop with Windows Vista Ultimate I used Windows "Notepad" to enter and edit the PostScript code and I used Acrobat Distiller 9 Pro to test it with.

I sent you a private message about e-mailing me the attachments that didn't show up in the post.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Dec 30, 2010 Dec 30, 2010
LATEST

As I noted, Ifound your answer very helpful. Thank you one more time!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines