As part of TeXnicard, I wrote many PostScript procedures. Many of them are not usable outside of TeXnicard, but a few of them are. Maybe you might
find some of them useful; I don't know. But I found it useful.
The multiget procedure is used to retrieve multiple entries from a dictionary, and put them into an array. It might be useful with
writeobject or with some other things too. (Unfortunately, this implementation does not work with objects other than dictionaries, since known is only compatible with dictionaries.)
/multiget { %( dict array -- array )
<< >> begin
exch /A exch def
/B 1 index length def
{
A 1 index known {
A exch get
} {
pop null
} ifelse
} forall
B array astore
end
} bind def
On Tuesday, April 14, 2020 at 6:17:41 PM UTC-5, ne...@zzo38computer.org.invalid wrote:
As part of TeXnicard, I wrote many PostScript procedures. Many of them are not usable outside of TeXnicard, but a few of them are. Maybe you might find some of them useful; I don't know. But I found it useful.
The multiget procedure is used to retrieve multiple entries from a dictionary, and put them into an array. It might be useful with
writeobject or with some other things too. (Unfortunately, this implementation does not work with objects other than dictionaries, since known is only compatible with dictionaries.)
/multiget { %( dict array -- array )
<< >> begin
exch /A exch def
/B 1 index length def
{
A 1 index known {
A exch get
} {
pop null
} ifelse
} forall
B array astore
end
} bind def
Interesting stuff. I came up with a shorter version of this which doesn't need a local dict. But it doesn't work with bind since it modifies the internal proc.
/map { [ 3 1 roll forall ] } def
/mg {
{ DICT exch { get } stopped { pop pop null } if }
dup 0 5 -1 roll put map
} def
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 293 |
Nodes: | 16 (2 / 14) |
Uptime: | 241:56:55 |
Calls: | 6,624 |
Files: | 12,175 |
Messages: | 5,320,145 |