nowlin@ihuxy.ATT.COM (Jerry Nowlin) (06/28/88)
I'm learning PS slowly and have a couple questions. I have all three Adobe books and have tried to infer one thing in particular to no avail. How do you concatenate several strings together into one in PS? A small example would be worth a thousand words. I have tried "copy" and "put" but my programming environment is becoming a real source of frustration. My big problem is that I have to write a program, send it out over the network to a laser printer and then walk down to the printer to see if I got some printout or not. If I screwed anything up I get no output at all. It makes debugging a real pleasure. Has anyone found some more reasonable alternatives to this scenario? I have UNIX or MS-DOS at my disposal but so far nothing that can display PS but that laser printer. Thanks. Jerry
bkc@sun.soe.clarkson.edu (Brad Clements) (07/01/88)
From article <2564@ihuxy.ATT.COM>, by nowlin@ihuxy.ATT.COM (Jerry Nowlin): > > My big problem is that I have to write a program, send it out over the > network to a laser printer and then walk down to the printer to see if I > got some printout or not. If I screwed anything up I get no output at > all. It makes debugging a real pleasure. Has anyone found some more Here are some suggestions that work for me. 1. Get ehandler.ps from the adobe server and make sure that it is downloaded and resident in your laser printer. This way, if you do get an error, at least you will get a printout of the cause of the error, and more importantly, a hardcopy dump of the stack contents. 2. If you have a MSDOS machine connected directly to your laser printer, you can use a terminal program (such as kermit) that will allow you to send the file (ASCII upload) and see what the printer responds with. Also, you can place the printer in executive mode and try out various PS commands and get immediate responses on your screen. You can also do this with a unix connection, use CU or TIP to connect to the ttyport that the laser printer is connected to and place the printer in executive mode. Executive mode doesn't kill your job when you create an error, prints out the cause of the error (on your terminal) and you can see the stack using pstack or == etc. To get the ehandler, send the following message to adobe!ps-file-server@decwrl.dec.com send programs ehandler.ps Be sure to change the password that is stored in the ehandler to match the password for your printer (0 is the default) and send the file to the printer. Hope this helps. Brad ! following is a quick script of a simple executive session with a PostScript printer connected to a unix system via a terminal server. Script started on Fri Jul 1 13:02:21 1988 % telnet myprinter.clarkson.edu Trying... Connected to myprinter.clarkson.edu. Escape character is '^]'. %%[ status: idle ]%% % I pressed ^T here % I typed executive PostScript(r) Version 44.0 Copyright (c) 1986 Adobe Systems Incorporated. PS> PS>5 4 add PS>pstack 9 PS>[ 8 9 7 6 5 4] PS>pstack [8 9 7 6 5 4 ] 9 PS>quit telnet> quit Connection closed. % ^D script done on Fri Jul 1 13:03:08 1988
greid@ondine.COM (Glenn Reid) (07/04/88)
>I'm learning PS slowly and have a couple questions. I have all three >Adobe books and have tried to infer one thing in particular to no avail. >How do you concatenate several strings together into one in PS? A small >example would be worth a thousand words. I have tried "copy" and "put" >but my programming environment is becoming a real source of frustration. Jerry, There is no inherent mechanism for string concatenation in the PostScript language. Basically you have to allocate a new string and copy the existing ones into it. You might also pause to consider carefully why you want to concatenate the strings: you might not need to (for example, if you are going to print them sequentially, all you have to do is call "show" for each string--the current point is left at the right spot after each show, and the next string is printed right where you would expect). Anyway, here is a procedure that should help (be aware that it uses memory each time it is called, equal to the sum of the lengths of the strings you are concatenating): %!PS-Adobe-2.0 %%Title: stringcat.ps %%EndComments /cat { %def % concatenates two strings and leaves the result on the stack dup length 2 index length add string% new string dup 4 -1 roll % pull (one) to top dup length 3 1 roll % save <length> for later 0 exch putinterval % () 0 (one) putinterval 1 index exch % keep one last copy of () 4 -1 roll putinterval % () <length> ( two) putinterval % leaves last copy of () on stack } bind def /scratch 3 dict def /cat2 { %def % uses variables instead of the stack; take your pick scratch begin /str2 exch def /str1 exch def % save from stack /resultstr % compute length, allocate string str1 length str2 length add string def resultstr 0 str1 putinterval % putinterval str1 at 0 resultstr str1 length str2 putinterval % putinterval str2 at length(str1) resultstr % leave result string on stack end } bind def %%EndProlog (one) ( two) cat == (first ) (second) cat2 dup == %%Trailer % I hope this helps. % % Glenn Reid % Adobe Systems
nowlin@ihuxy.ATT.COM (Jerry Nowlin) (07/07/88)
In article <4059@adobe.COM>, greid@ondine.COM (Glenn Reid) writes: > There is no inherent mechanism for string concatenation in the > PostScript language. Basically you have to allocate a new string > ... > Anyway, here is a procedure that should help (be aware that it uses > memory each time it is called, equal to the sum of the lengths of the > strings you are concatenating): > ... > Glenn Reid > Adobe Systems I first want to thank all the people who responded directly to my initial request as well as those that responded in this group. I have multiple string concatenation routines now and eventually realized (as Glenn pointed out) that I didn't need it anyway. The next question I have is one directed toward the importance of efficiency in programming in PostScript. I have experience in programming for efficiency in languages like C and assembler. The constant effort to conserve bytes and cycles can really effect the style used. How important is efficiency in PostScript? How wasteful is the use of variables as opposed to the sometimes (to me) obscure stack management schemes that are used in some of the examples posted to this group. I've noticed the green book talks about memory management and real-time efficiency. How important are these in general? Is the green book the best place to find out how to write efficient PostScript? Jerry Nowlin (...!ihnp4!ihuxy!nowlin)
roy@phri.UUCP (Roy Smith) (07/08/88)
In article <2574@ihuxy.ATT.COM> nowlin@ihuxy.ATT.COM (Jerry Nowlin) writes: > How important is efficiency in PostScript? A related question which has been nagging at me for a while is how to decide how to split the computational complexity between the printer and the PS-generating program. For example, let's say you wanted to draw a black-filled arrow at a 45-degree angle. One possibility would be to use a "arrow" routine like the one shown in the PostScript Tutorial (blue book) to draw an arrow aligned with the coordinate axis and precede it by "45 rotate" to change the coordinate system. Another possibility would be to compute the coordinates of the verticies of the arrow in the current corrdinate system and just do a series of linetos followed by a fill. In the first example, you're letting the printer do the coordinate transformations. In the second, you do them yourself. Similarly, you might have a choice between "/inch {72 mul} def 0.5 inch 0.5 inch lineto" and "36 36 lineto". The decision as to which is better depends on the relative speeds of the printer and the machine on which the PS-generating program is runs. Clearly, a Macintosh producing PS code for a PrintServer-40 has different tradeoffs from a Cray producing code for a LaserWriter. How does one decide? -- Roy Smith, System Administrator Public Health Research Institute {allegra,philabs,cmcl2,rutgers}!phri!roy -or- phri!roy@uunet.uu.net "The connector is the network"
rwl@uvacs.CS.VIRGINIA.EDU (Ray Lubinsky) (07/12/88)
In article <3372@phri.UUCP>, roy@phri.UUCP (Roy Smith) writes: > In article <2574@ihuxy.ATT.COM> nowlin@ihuxy.ATT.COM (Jerry Nowlin) writes: > > How important is efficiency in PostScript? > > A related question which has been nagging at me for a while is how > to decide how to split the computational complexity between the printer and > the PS-generating program. For example, let's say you wanted to draw a > black-filled arrow at a 45-degree angle. One possibility would be to use a > "arrow" routine like the one shown in the PostScript Tutorial (blue book) to > draw an arrow aligned with the coordinate axis and precede it by "45 rotate" > to change the coordinate system. Another possibility would be to compute > the coordinates of the verticies of the arrow in the current corrdinate > system and just do a series of linetos followed by a fill. Well, just to through some fuel on the fire, it takes about 5 to 6 minutes to display a dump of my Sun workstation screen on our LaserWriter Plus -- essentially the time that it takes all those bytes to travel down the 9600 bps serial line. Now, to have the printer turn the image on its side to landscape mode (with "90 rotate") it take 30 minutes! Definitely a place where you'd want to do the rotation on the host computer. . . . . -- | Ray Lubinsky, UUCP: ...!uunet!virginia!uvacs!rwl | | Department of BITNET: rwl8y@virginia | | Computer Science, CSNET: rwl@cs.virginia.edu -OR- | | University of Virginia rwl%uvacs@uvaarpa.virginia.edu |