Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

drawing irregular grid, and trying to debug code in general?

drawing irregular grid, and trying to debug code in general?

drawing irregular grid, and trying to debug code in general?

I am trying to write substantial algorithms in postscript and finding
it hard going. There are two questions inherent in this post.  First,
how can I solve the problem. Second, rather than just giving me the
answers, is there any decent way of stepping through postscript code
so I can debug it? I am using gs on linux; if there are better tools,
great. If there aren't, do any of you have little subroutines to
display intermediate values, or techniques to help? I programmed in
forth ages ago but find the stack machine to be difficult to code. No
doubt part of that is just my rusty skills.

First, I want to setup a color table to index values 0-127 to rgb triples.
I try to index from [0 0 1] to [1 0 0]

384 /palettesize store
/palettesize load string /nyhopscolormap store
/red 0 store
/green 0 store
/blue 255 store
0 3 /palettesize load
    /i exch store
    /nyhopscolormap load /i load /red/ load put
    /nyhopscolormap load /i load 1 add /green load put
    /nyhopscolormap load /i load 2 add /blue load put
    /red load 2 add /red store
    /blue load 2 add /blue store
} for

[/nyhops DeviceRGB 255 /nyhopscolormap load] setcolorspace

Then, I want to create an array of x,y locations, each with a value.
A low-tech way might be:

    [-74,40, 1], [-73.99,40.05, 1.2], [-73.99, 40.085, 1.21]
    [-73.95,40, 1.01], [-73.956,40.061, 1.11], [-73.99, 40.09, 1.14]
    [-73.92,40, 1.01], [-73.912,40.059, 1.11], [-73.93, 40.089, 1.4]

This describes a 2d grid. I'm aware that I could encode this better
using ascii or binary, but that's a detail. I'd like to traverse this grid, connecting each adjacent quadrilateral (they aren't squares), coloring them.

I could of course just generate code like:

1 setcolor
-74,40 moveto
-73.99,40.05 lineto
-73.95,40 lineto
-73.956,40.061 lineto

and just repeat, but this bothers me. I'd rather be able to write a
loop that processes this repettetive data and just process the
data. Whenever I try, it fails, and I have no good way to debug pieces
at a time until I have a working entity. If I mistype a token, I can
see in the dump from gs that it failed on that token, but otherwise I
just get an error at position xxxx which is better than nothing, but
not much better (and I am trying to find byte xxx in emacs, which no doubt has a command). Any suggestions would be greatfully appreciated.

RE: drawing irregular grid, and trying to debug code in general?

Best debug tool I know of is PSAlter from www.quite.com in Scotland.

It lets you walk through the code while you watch the stack pushing and popping.

RE: drawing irregular grid, and trying to debug code in general?

You can yse -dESTACKPRINT flag to print out the execution stack in Ghostscript. You can also check what shading fill
can do for you in Level 3.

Regarding the grid structure, the arrays use memory and cause expensive garbage collection. Besides, even a simple PS operator takes over 100 computer commands. I vote for the moveto-lineto approach. Besides, PostScript is almost always converted to PDF, which unrolls all the loops. So why bother?

Your PostScript expert is just a click away.

RE: drawing irregular grid, and trying to debug code in general?

There is a program call PSAlter ( http://www.quite.com/psalter/psalter.htm )which appears to be a PostScript debugger.

I have NO experience with the product and cannot say whether it would help solve your problems.

It costs about £200 + VAT so it's not an insignificant investment!

Let me know if you DO purchase and it's any good!!

Mark H., AFX

RE: drawing irregular grid, and trying to debug code in general?

afx- see my previous post.

Quite will let you have a evaluation key if you ask.


Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close