Path: utzoo!utgpu!watmath!att!dptg!rutgers!tut.cis.ohio-state.edu!gem.mps.ohio-state.edu!rpi!image.soe.clarkson.edu!bkc From: bkc@image.soe.clarkson.edu (Brad Clements) Newsgroups: comp.lang.postscript Subject: Re: Case statements in Postscript Message-ID: <1989Aug30.151133.21046@sun.soe.clarkson.edu> Date: 30 Aug 89 15:11:33 GMT References: <7573@cg-atla.UUCP> Sender: bkc@sun.soe.clarkson.edu (Brad Clements) Organization: Clarkson University, Potsdam, NY Lines: 37 From article <7573@cg-atla.UUCP>, by kincaid@cg-atla.UUCP (Tom Kincaid ): > If I have a postscript variable V1 that can have a value > 1 2 3 or 4 and I want to execute > > /proc1 if V1 = 1 > /proc2 if V1 = 2 > /proc3 if V1 = 3 > /proc4 if V1 = 4 > > What is the best way to write the code ? Is there a case > statement of some sort ? This is cheap. Not in processing time though... % define proc1 through proc4 /case_array [ /proc1 load /proc2 load /proc3 load /proc4 load ] def .... % suppose V1 now has a value between 1 and 4 case_array v1 1 sub get exec % presto, all done. Better off letting V1 have values 0 through 3 | Brad Clements bkc@omnigate.clarkson.edu bkc@clutx.bitnet | Network Engineer Clarkson University (315)268-2292 -- | Brad Clements bkc@omnigate.clarkson.edu bkc@clutx.bitnet | Network Engineer Clarkson University (315)268-2292