[comp.lang.postscript] Test for nocurrentpoint

erja@daimi.dk (Erik Jacobsen) (10/10/89)

How can I test if there is no currentpoint, or the current path
is empty? I would like something like this:


         thereisacurrentpoint { pathbbox ..... }
                              { .....          } ifelse

Erik

--------------------------------------------------------------------
Erik Jacobsen,     Computer Science Department,    Aarhus University
Ny Munkegade,    Building 540,       DK-8000 Aarhus C,       Denmark

Phone: +45 86127188, Telefax: +45 86135725, Home phone: +45 86169199
         Internet: erja@daimi.dk,           Ham-radio: OZ6KS

erja@epimetheus.dk (Erik Jacobsen) (10/10/89)

In article <3439@daimi.dk> I write:
>
>How can I test if there is no currentpoint, or the current path
>is empty? I would like something like this:
>
>
>         thereisacurrentpoint { pathbbox ..... }
>                              { .....          } ifelse

The answer: To test if pathbbox executes with an error, you can do this:

          {pathbbox} stopped { ActionIfError } { ActionIfOk } ifelse

Thanks to jlk@daimi.dk

Erik

--------------------------------------------------------------------
Erik Jacobsen,     Computer Science Department,    Aarhus University
Ny Munkegade,    Building 540,       DK-8000 Aarhus C,       Denmark

Phone: +45 86127188, Telefax: +45 86135725, Home phone: +45 86169199
         Internet: erja@daimi.dk,           Ham-radio: OZ6KS

cet1@cl.cam.ac.uk (C.E. Thompson) (10/11/89)

In article <3439@daimi.dk>, erja@daimi.dk (Erik Jacobsen) writes:
> How can I test if there is no currentpoint, or the current path
> is empty? I would like something like this:
>
>          thereisacurrentpoint { pathbbox ..... }
>                               { .....          } ifelse

Nice question! The best I can come up with is

/thereisacurrentpoint {
  mark false {cleartomark mark true} dup dup dup pathforall
  exch pop } def

(Using the marks is just a way of being able to use the same procedure
for all four arguments to 'pathforall'.)

Chris Thompson
JANET:    cet1@uk.ac.cam.phx
Internet: cet1%phx.cam.ac.uk@nsfnet-relay.ac.uk