Thread View: comp.lang.postscript
3 messages
3 total messages
Started by Rob Bradlee
Mon, 12 Oct 1992 17:34
Version of concatenate which does use VM
Author: Rob Bradlee
Date: Mon, 12 Oct 1992 17:34
Date: Mon, 12 Oct 1992 17:34
52 lines
2369 bytes
2369 bytes
I was using Glenn Reid's concatenate routine (from "Thinking in PostScript")
in some system PostScript (outside the server loop). However, each
invocation consumes some VM, so I wrote a version that takes the destination
string or array as a passed in parameter. This way, if you don't want to
bracket the code in a save/restore pair, you can use a predeclared string
to store the result (and reuse the same string later). Any comments or
corrections welcome.
------------------------- cut here ------------------------------------
%!
%%*****************************************************************************
%% concatenate
%%*****************************************************************************
% concatenate
% concats either two strings or two arrays.
% Modified from Glenn Reid's "Thinking in PostScript". Caller now
% passes in the destination string or array so that the routine itself
% does not allocate any VM.
% Result is string3 = string1 + string2
%
/concatenate % (string1) (string2) (string3) concatenate string3
% [array1] [array2] [array3] concatenate array3
{
dup type 2 index type 2 copy ne % chech that both inputs are same
{
pop pop
errordict begin (concatenate) typecheck end
}
{
/stringtype ne exch /arraytype ne and % must be string or array
{
errordict begin (concatenate) typecheck end
} if
} ifelse
3 1 roll
dup length 2 index length % st: str3 str1 str2 len2 len1
add % st: str3 str1 str2 len1+2
3 index length exch lt % Make sure there is enough room in dest
{
errordict begin (concatenate) rangecheck end
} if
3 -1 roll % st: str1 str2 str3
dup 0 4 index putinterval % str1 str2 str3(w/str1)
dup 4 -1 roll length 4 -1 roll putinterval
} def % concatenate
--
Rob Bradlee w:(508)-658-5600 X5153
Agfa Corporation. ...!{decvax}!cg-atla!bradlee
200 Ballardvale St. bradlee@cg-atla.agfa.com
Wilmington, Mass. 01887
Re: Version of concatenate which does use VM
Author: Glenn Reid
Date: Wed, 14 Oct 1992 08:29
Date: Wed, 14 Oct 1992 08:29
21 lines
1159 bytes
1159 bytes
Rob Bradlee writes > I was using Glenn Reid's concatenate routine (from "Thinking in PostScript") > in some system PostScript (outside the server loop). However, each > invocation consumes some VM, so I wrote a version that takes the destination > string or array as a passed in parameter. Nice work, Rob. That reminds me. You asked a question a few weeks ago about one of the examples in my book, and I wrote a long message about it, but there wasn't a single response to it, so I wondered if it got out there at all. Did anybody see it? Does anybody care? :-) Glenn -- Glenn Reid NeXTmail: glenn@rightbrain.com RightBrain Software 415-326-2974 (NeXTfax 326-2977) Palo Alto, California Electronic Frontier Foundation, member #054
Re: Version of concatenate which does use VM
Author: Rob Bradlee
Date: Wed, 14 Oct 1992 12:21
Date: Wed, 14 Oct 1992 12:21
34 lines
1817 bytes
1817 bytes
In article <907@rtbrain.rightbrain.com> glenn@rightbrain.com writes:
>That reminds me. You asked a question a few weeks ago about one of
>the examples in my book, and I wrote a long message about it, but there
>wasn't a single response to it, so I wondered if it got out there at all.
>Did anybody see it? Does anybody care? :-)
>
>Glenn
>
Sorry I didn't email you or followup. Yes, I definitely cared about your response
and much appreciated it. (Your reply coincided with a work crisis).
Based on your response I decided to leave my inherited code alone
(i.e. let it do errordict /typecheck get exec not errordict begin typecheck end).
I apologize for not properly responding.
And while I have you here, I have another question which you might find
interesting. What about the technique of using non-name keys in dictionaries.
For instance if you wanted to execute a different proc for every resolution you
could create a dict with the resolution (as an integer) as the key:
3 dict begin
300 {} def
600 {} def
1200 {} def
end
However, I think you run into some syntax problems with this approach. Have you ever
successful used it?
--
Rob Bradlee w:(508)-658-5600 X5153
Agfa Corporation. ...!{decvax}!cg-atla!bradlee
200 Ballardvale St. bradlee@cg-atla.agfa.com
Wilmington, Mass. 01887
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads