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


Groups > comp.lang.postscript > #1961

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

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.tele2net.at!news.panservice.it!feed.xsnews.nl!border02.ams.xsnews.nl!feeder01.ams.xsnews.nl!frontend-F10-12.ams.news.kpn.nl
From Cecil Westerhof <Cecil@decebal.nl>
Newsgroups comp.lang.postscript
Subject Re: cvx before storing works in one place, but not in another
Organization Decebal Computing
References <87iom5sdnq.fsf@Equus.decebal.nl> <c35ccf26-0b4c-4835-a2df-2b570e842dfb@googlegroups.com>
X-Face "(y8cC@tg_12{">GF'UXTW]FHI2wMiZNrnf'1EFQ&O#$m:f#O7+7}kR<J%a^F2lh4[N~Yz4 nSp#c+aQo1b5=?HcNEkQ7QzF<])O3X4MDL/AYjys&*mt>,v+Pti8=Vi/Z"g^?b"E
X-Homepage http://www.decebal.nl/
Date Thu, 07 Aug 2014 14:45:42 +0200
Message-ID <87a97gsc21.fsf@Equus.decebal.nl> (permalink)
User-Agent Gnus/5.13 (Gnus v5.13) Emacs/24.2 (gnu/linux)
Cancel-Lock sha1:yMGnA6Z9PI2cTrcrYdQPuR8LeuI=
MIME-Version 1.0
Content-Type text/plain
Lines 75
NNTP-Posting-Host 77.171.42.144
X-Trace 1407416486 news.kpn.nl 11909 77.171.42.144@kpn/77.171.42.144:60243
Xref csiph.com comp.lang.postscript:1961

Show key headers only | View raw


Op Thursday 7 Aug 2014 07:01 CEST schreef luser:

>> /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-
>
> That much makes sense. But you should be getting the same error 
> with the original code if you're doing
>
> borderPart exec
>
> If borderPart is defined as an executable string, then mentioning
> the executable name `borderPart` will load and execute the string,
> yielding an executable name borderPartN, and executing that as well.
>
> I'd write your switch statement a little more concisely
>
> /mydict <<
> 1 /borderPart1 cvx
> 2 /borderPart2 cvx
> 3 /borderPart3 cvx
> 4 /borderPart4 cvx
> 5 /borderPart5 cvx
> /default 1 index
>>> def
> mydict 1 index known not {pop /default} if
> mydict exch get
> /borderPart exch def

I went for:
    /mydict <<
        1        /borderPart1
        2        /borderPart2
        3        /borderPart3
        4        /borderPart4
        5        /borderPart5
        /default /BorderPart1
    >> def
    dup mydict exch known {
        mydict exch get
    } {
        pop
        mydict /default get
    } ifelse
    /borderPart exch def

Putting cvx behind the definitions went wrong. Also
    /default 1 index 
went wrong.

I look in it/the rest later.

Thanks for the info.

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

Back to comp.lang.postscript | Previous | Next — Previous in thread | 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