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


Groups > comp.lang.postscript > #1192 > unrolled thread

Keeping values of a temporary dictionary

Started byCecil Westerhof <Cecil@decebal.nl>
First post2012-12-26 14:52 +0100
Last post2012-12-26 15:34 -0800
Articles 7 — 3 participants

Back to article view | Back to comp.lang.postscript


Contents

  Keeping values of a temporary dictionary Cecil Westerhof <Cecil@decebal.nl> - 2012-12-26 14:52 +0100
    Re: Keeping values of a temporary dictionary Cecil Westerhof <Cecil@decebal.nl> - 2012-12-26 18:21 +0100
      Re: Keeping values of a temporary dictionary Cecil Westerhof <Cecil@decebal.nl> - 2012-12-26 19:02 +0100
        Re: Keeping values of a temporary dictionary Cecil Westerhof <Cecil@decebal.nl> - 2012-12-27 17:52 +0100
          Re: Keeping values of a temporary dictionary sjprouty3765@gmail.com - 2012-12-28 12:31 -0800
            Re: Keeping values of a temporary dictionary Cecil Westerhof <Cecil@decebal.nl> - 2012-12-28 22:54 +0100
      Re: Keeping values of a temporary dictionary luser- -droog <mijoryx@yahoo.com> - 2012-12-26 15:34 -0800

#1192 — Keeping values of a temporary dictionary

FromCecil Westerhof <Cecil@decebal.nl>
Date2012-12-26 14:52 +0100
SubjectKeeping values of a temporary dictionary
Message-ID<87han8c43o.fsf@Compaq.site.inet>
I am trying to set colours to use depending on an input varable. I
have the following code:
    currentdict
    /setColours 5 dict def
    %setColours begin
        /previousDict exch def
        /LG_BL_YE {
            /gradient1 { colorLimeGreen         } def
            /gradient2 { colorBlue              } def
            /textColor { colorYellow            } def
        } def
        /FG_MFG_YE {
            /gradient1 { colorForestGreen       } def
            /gradient2 { colorMediumForestGreen } def
            /textColor { colorYellow            } def
        } def
        /FG_MFG_WH {
            /gradient1 { colorForestGreen       } def
            /gradient2 { colorMediumForestGreen } def
            /textColor { colorWhite             } def
        } def
        /FG_MFG_DG {
            /gradient1 { colorForestGreen       } def
            /gradient2 { colorMediumForestGreen } def
            /textColor { colorDarkGreen         } def
        } def
        COLOUR_SCHEME where {
            COLOUR_SCHEME get exec
        }{
            % ### message no COLOUR_SCHEME
            /gradient1 { colorNavy              } def
            /gradient2 { colorNavy              } def
            /textColor { colorYellow            } def
        } ifelse
        %previousDict /gradient1 { gradient1 } put
    %end

I would like to use the temporary dictionary setColours to set the
gradient and text colours. But when I remove the comments, the script
hangs. What is the correct way to do it?

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

[toc] | [next] | [standalone]


#1193

FromCecil Westerhof <Cecil@decebal.nl>
Date2012-12-26 18:21 +0100
Message-ID<87zk10afux.fsf@Compaq.site.inet>
In reply to#1192
Op woensdag 26 dec 2012 14:52 CET schreef Cecil Westerhof:

> I am trying to set colours to use depending on an input varable. I
> have the following code:
> currentdict
> /setColours 5 dict def
> %setColours begin
> /previousDict exch def
> /LG_BL_YE {
> /gradient1 { colorLimeGreen         } def
> /gradient2 { colorBlue              } def
> /textColor { colorYellow            } def
> } def
> /FG_MFG_YE {
> /gradient1 { colorForestGreen       } def
> /gradient2 { colorMediumForestGreen } def
> /textColor { colorYellow            } def
> } def
> /FG_MFG_WH {
> /gradient1 { colorForestGreen       } def
> /gradient2 { colorMediumForestGreen } def
> /textColor { colorWhite             } def
> } def
> /FG_MFG_DG {
> /gradient1 { colorForestGreen       } def
> /gradient2 { colorMediumForestGreen } def
> /textColor { colorDarkGreen         } def
> } def
> COLOUR_SCHEME where {
> COLOUR_SCHEME get exec
> }{
> % ### message no COLOUR_SCHEME
> /gradient1 { colorNavy              } def
> /gradient2 { colorNavy              } def
> /textColor { colorYellow            } def
> } ifelse
> %previousDict /gradient1 { gradient1 } put
> %end
>
> I would like to use the temporary dictionary setColours to set the
> gradient and text colours. But when I remove the comments, the
> script hangs. What is the correct way to do it?

Found it:
    /setColourScheme 25 dict def
    setColourScheme begin
        /FG_MFG_DG {
            /gradient1 { colorForestGreen       } def
            /gradient2 { colorMediumForestGreen } def
            /textColor { colorDarkGreen         } def
        } def
        /FG_MFG_WH {
            /gradient1 { colorForestGreen       } def
            /gradient2 { colorMediumForestGreen } def
            /textColor { colorWhite             } def
        } def
        /FG_MFG_YE {
            /gradient1 { colorForestGreen       } def
            /gradient2 { colorMediumForestGreen } def
            /textColor { colorYellow            } def
        } def
        /LG_BL_YE {
            /gradient1 { colorLimeGreen         } def
            /gradient2 { colorBlue              } def
            /textColor { colorYellow            } def
        } def
        /MBL_MBL_OL {
            /gradient1 { colorMediumBlue        } def
            /gradient2 { colorMediumBlue        } def
            /textColor { colorOlive             } def
        } def
        /NA_NA_YE {
            /gradient1 { colorNavy              } def
            /gradient2 { colorNavy              } def
            /textColor { colorYellow            } def
        } def
        /NA_NAB_YE {
            /gradient1 { colorNavy              } def
            /gradient2 { colorNavyBlue          } def
            /textColor { colorYellow            } def
        } def
        /OR_ORR_YE {
            /gradient1 { colorOrange            } def
            /gradient2 { colorOrangeRed         } def
            /textColor { colorYellow            } def
        } def
        /PU_IND_YE {
            /gradient1 { colorPurple            } def
            /gradient2 { colorIndigo            } def
            /textColor { colorYellow            } def
        } def
        /RE_RE_YE {
            /gradient1 { colorRed               } def
            /gradient2 { colorRed               } def
            /textColor { colorYellow            } def
        } def
        /SCA_SCA_YE {
            /gradient1 { colorScarlet           } def
            /gradient2 { colorScarlet           } def
            /textColor { colorYellow            } def
        } def
        /SIE_SIE_VDB {
            /gradient1 { colorSienna            } def
            /gradient2 { colorSienna            } def
            /textColor { colorVeryDarkBrown     } def
        } def
        /SKB_SKB_NA {
            /gradient1 { colorSkyBlue           } def
            /gradient2 { colorSkyBlue           } def
            /textColor { colorNavy              } def
        } def
        /YEG_YEG_NA {
            /gradient1 { colorYellowGreen       } def
            /gradient2 { colorYellowGreen       } def
            /textColor { colorNavy              } def
        } def
        COLOUR_SCHEME where {
            COLOUR_SCHEME get exec
        }{
            % ### message no COLOUR_SCHEME
            /gradient1 { colorNavy              } def
            /gradient2 { colorNavy              } def
            /textColor { colorYellow            } def
        } ifelse
    end
    /gradient1 setColourScheme /gradient1 get def
    /gradient2 setColourScheme /gradient2 get def
    /textColor setColourScheme /textColor get def

Maybe I should write a function to retrieve the values.
Not very important, but is it possible to delete setColourScheme? It
has no use after this.

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

[toc] | [prev] | [next] | [standalone]


#1194

FromCecil Westerhof <Cecil@decebal.nl>
Date2012-12-26 19:02 +0100
Message-ID<87txr8adz0.fsf@Compaq.site.inet>
In reply to#1193
Op woensdag 26 dec 2012 18:21 CET schreef Cecil Westerhof:

> /gradient1 setColourScheme /gradient1 get def
> /gradient2 setColourScheme /gradient2 get def
> /textColor setColourScheme /textColor get def
>
> Maybe I should write a function to retrieve the values.

Done:
    /getDictValues { % dictionary nameArray
        {
            dup
            3 -1 roll
            dup
            4 1 roll
            exch
            get def
        } forall
        pop
    } def

    setColourScheme [/gradient1 /gradient2 /textColor] getDictValues

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

[toc] | [prev] | [next] | [standalone]


#1196

FromCecil Westerhof <Cecil@decebal.nl>
Date2012-12-27 17:52 +0100
Message-ID<87wqw3igjh.fsf@Compaq.site.inet>
In reply to#1194
Op woensdag 26 dec 2012 19:02 CET schreef Cecil Westerhof:

> Op woensdag 26 dec 2012 18:21 CET schreef Cecil Westerhof:
>
>> /gradient1 setColourScheme /gradient1 get def
>> /gradient2 setColourScheme /gradient2 get def
>> /textColor setColourScheme /textColor get def
>>
>> Maybe I should write a function to retrieve the values.
>
> Done:
> /getDictValues { % dictionary nameArray
> {
> dup
> 3 -1 roll
> dup
> 4 1 roll
> exch
> get def
> } forall
> pop
> } def
>
> setColourScheme [/gradient1 /gradient2 /textColor] getDictValues

Because I do not need the dict setColourScheme anymore I changed it
to:
    currentdict setsetColourScheme [/gradient1 /gradient2 /textColor] getDictValues
    (after getDictValues) ==
    pstack
    currentdict setColourScheme undef
    (after undef) ==
    pstack
    setColourScheme /gradient1 get
    (after fetch) ==
    pstack

The == and pstack are to check. I get:
    (after getDictValues)
    (after undef)
    (after fetch)
    {colorForestGreen}

So setColourScheme is not deleted. Why not?

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

[toc] | [prev] | [next] | [standalone]


#1206

Fromsjprouty3765@gmail.com
Date2012-12-28 12:31 -0800
Message-ID<759e2382-0235-49b4-a9d5-a83cf4f4d4a9@googlegroups.com>
In reply to#1196
"currentdict setColourScheme undef" is incorrect syntax.  It should be "currentdict /setColourScheme undef".

[toc] | [prev] | [next] | [standalone]


#1207

FromCecil Westerhof <Cecil@decebal.nl>
Date2012-12-28 22:54 +0100
Message-ID<877go1j109.fsf@Compaq.site.inet>
In reply to#1206
Op vrijdag 28 dec 2012 21:31 CET schreef sjprouty:

> "currentdict setColourScheme undef" is incorrect syntax. It should
> be "currentdict /setColourScheme undef".

That solved it. Thanks.

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

[toc] | [prev] | [next] | [standalone]


#1195

Fromluser- -droog <mijoryx@yahoo.com>
Date2012-12-26 15:34 -0800
Message-ID<e2d85375-ce55-4009-afbc-97a42cc7df7f@googlegroups.com>
In reply to#1193
On Wednesday, December 26, 2012 11:21:58 AM UTC-6, Cecil Westerhof wrote:

>     end
> 
>     /gradient1 setColourScheme /gradient1 get def
> 
>     /gradient2 setColourScheme /gradient2 get def
> 
>     /textColor setColourScheme /textColor get def
> 
> 
> 
> Maybe I should write a function to retrieve the values.
> 
> Not very important, but is it possible to delete setColourScheme? It
> 
> has no use after this.
> 

Just move the 'end' to the end. Until then, everything's available through normal lookup.

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.postscript


csiph-web