Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.postscript > #1952

cvx before storing works in one place, but not in another

From Cecil Westerhof <Cecil@decebal.nl>
Newsgroups comp.lang.postscript
Subject cvx before storing works in one place, but not in another
Organization Decebal Computing
Date 2014-08-06 19:58 +0200
Message-ID <87iom5sdnq.fsf@Equus.decebal.nl> (permalink)

Show all headers | View raw


I had the following code:
    dup 5 eq {
        /borderPart (borderPart5) cvx def
    } {
        dup 4 eq {
            /borderPart (borderPart4) cvx def
        } {
            dup 3 eq {
                /borderPart (borderPart3) cvx def
            } {
                dup 2 eq {
                    /borderPart (borderPart2) cvx def
                } {
                    /borderPart (borderPart1) cvx def
                } ifelse
            } ifelse
        } ifelse
    } ifelse

Not very neat, so I made a kind of switch statement:
    /mydict 6 dict def
    mydict         1 (borderPart1) put
    mydict         2 (borderPart2) put
    mydict         3 (borderPart3) put
    mydict         4 (borderPart4) put
    mydict         5 (borderPart5) put
    mydict (default) (borderPart5) put
    dup mydict exch known {
        mydict exch get
    } {
        pop
        mydict (default) get
    } ifelse
    /borderPart exch def

Works fine, but there is a strange difference. The last statement can
not be:
    /borderPart exch cvx def

If I do that I get at the place the function is executed:
   Error: /stackunderflow in --exec-

Also strange, if I after
    /borderPart exch cvx def
do:
    /borderPart ==
this gives:
    /borderPart

Without the number.
What could be happening here?

It is not very important: I just do a cvx before the exec, but I am
just curious. ;-)

-- 
Cecil Westerhof
Senior Software Engineer
LinkedIn: http://www.linkedin.com/in/cecilwesterhof

Back to comp.lang.postscript | Previous | Next — Next in thread | Find similar | Unroll thread


Thread

cvx before storing works in one place, but not in another Cecil Westerhof <Cecil@decebal.nl> - 2014-08-06 19:58 +0200
  Re: cvx before storing works in one place, but not in another luser- -droog <mijoryx@yahoo.com> - 2014-08-06 22:01 -0700
    Re: cvx before storing works in one place, but not in another Cecil Westerhof <Cecil@decebal.nl> - 2014-08-07 14:45 +0200
      Re: cvx before storing works in one place, but not in another luser- -droog <mijoryx@yahoo.com> - 2014-08-14 01:15 -0700
  Re: cvx before storing works in one place, but not in another jdaw1 <jdawiseman@gmail.com> - 2014-08-10 07:41 -0700

csiph-web