• browse-dict -- Thinking in Postscript Example 10.9 on page 128

    From douglas.mcallaster@gmail.com@21:1/5 to All on Mon Mar 23 07:03:21 2020
    Folks,

    Below does not work as shown in subject text.
    Can someone fix or offer a better solution?

    Thx, Doug
    ======snip=============
    /browse-dict % dictionary browse-dict -
    { %def
    { %forall
    exch (key: ) print ==
    dup type
    dup /dicttype eq { %ifelse
    (subdictionary: ) print
    browse-dict % recursively browse dictionary
    }{
    (value: ) print ==
    } ifelse
    } forall
    } bind def

    /testDict1 <<
    /a 1
    /b [ 1 2 3 ]
    /c <<
    /key1 4
    /key2 5
    /key3 6

    def

    testDict1
    browse-dict

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From luser droog@21:1/5 to douglas....@gmail.com on Mon Mar 23 07:26:28 2020
    On Monday, March 23, 2020 at 9:03:27 AM UTC-5, douglas....@gmail.com wrote:
    Folks,

    Below does not work as shown in subject text.
    Can someone fix or offer a better solution?

    Thx, Doug
    ======snip=============
    /browse-dict % dictionary browse-dict -
    { %def
    { %forall
    exch (key: ) print ==
    dup type
    dup /dicttype eq { %ifelse

    Remove the dup here. It's leaving an extra unneeded copy of the type.

    (subdictionary: ) print
    browse-dict % recursively browse dictionary
    }{
    (value: ) print ==
    } ifelse
    } forall
    } bind def

    /testDict1 <<
    /a 1
    /b [ 1 2 3 ]
    /c <<
    /key1 4
    /key2 5
    /key3 6

    def

    testDict1
    browse-dict

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)