%!PS % Some PostScript Disk access notes % ========================================= % by Don Lancaster % Copyright c 2002 by Don Lancaster & Synergetics, Box 809, Thatcher, AZ, 85552 % (928) 428-4073 Email: don@tinaja.com Website: http://www.tinaja.com % Consulting services available http://www.tinaja.com/info01.html % Linking welcome. Reposting expressly forbidden. % All commercial rights and all electronic media rights ~fully~ reserved. % Linking usually welcome. Reposting expressly forbidden. Version 1.1 % Gathers together some non-obvious utilities and routines for % PostScript Disk access % IMPORTANT NOTE: Don Lancaster's file gonzo.ps is required for this program. % After obvious location mods, uncomment ONE of the following two lines: (C:\\windows\\desktop\\gonzo\\gonzo.ps) run % use internal gonzo % (A:\\gonzo.ps) run % use external gonzo % NOTE THAT ALL PS FILENAME STRINGS !!!DEMAND!!! DOUBLE REVERSE SLASHES. % GONZO20A Guru Gonzo PostScript power tools (Interim release) % Includes gonzo justification and layout utilities. % Copyright c 1990, 1996, 2001 by Don Lancaster and Synergetics, Box 809, % Thatcher Arizona, 5552 (928) 428-4073 don@tinaja.com support % via http://www.tinaja.com All commercial rights and all electronic % media rights **FULLY** reserved. Reposting is expressly forbidden. %%%%%%%%%%% links menu directory %%%%%%%%%%%% % This code locks pdfmark commands out of a PostScript printer. /pdfmark where {pop}{userdict /pdfmark /cleartomark load put} ifelse % /surl "start url" marks the beginning of a text sequence to be urled. % It also paints the text blue... /surl {mark /blue cvx 0.33 /setgray cvx % change text to blue /currentpoint cvx % remember box start /urly /exch cvx /store cvx /urlx /exch cvx /store cvx ] cvx % complete deferred command printlist exch 3 index exch put % stuff into gonzo printlist exch 1 add exch % increment gonzo list count } def % /eurl "end url" unmarks the end of a text sequence and sets up % the pdfmark needed to define the Acrobat web link. /eurl {mark % start deferred proc exch % position url string % /black cvx 0 /setgray cvx % turn blue marker off % maintextcolor /setrgbcolor cvx % reset to main text color??? /aqua cvx /black cvx /makeurl cvx % defer call of url builder ] cvx % complete deferred proc printlist exch 3 index exch % stuff into gonzo printlist put exch 1 add exch % increment gonzo list count } def % /makeurl generates the pdfmark, receiving a {(urlstring) makeurl}. % Note that it is not called until formatted printlist time... /urlover 0.2 def % fraction of hot area over bounds /makeurl { /cururlname exch store % save the url string mark % start pdfmark currentfont /ScaleMatrix get 3 get /fsize exch store % guess height /Rect [ urlx fsize urlover mul sub % set box left x urly fsize urlover mul sub % set box left y currentpoint exch fsize urlover mul add exch fsize add ] /Border [ 0 0 0] % [0 0 0 ] = none; [0 0 2] = debug /Color [ .7 0 0 ] /Action <> /Subtype /Link /ANN % annotation type pdfmark % call pdf operators } def % /makeurlx generates the box specific pdfmark, receiving % a {(urlstring) makeurl}. % Note that it is not called until formatted printlist time... /makeurlx { /cururlnamex exch store % save the url string mark % start pdfmark /Rect [ xpos % set box left x ypos 0.9 sub % set box left y xpos 2.8 add % box right x ypos 0.9 sub 2.8 add % box right y ] /Border [ 0 0 0] % [0 0 0 ] = none; [0 0 2] = debug /Color [ .7 0 0 ] /Action <> /Subtype /Link /ANN % annotation type pdfmark % call pdf operators } def /maintextcolor {0 0 0 } def % text link specific data -- use dictionary instead below { /cubic01 {(http://www.tinaja.com/cubic01.asp) eurl} def /hack62 {(http://www.tinaja.com/glib/hack62.pdf) eurl} def /increment {(http://www.tinaja.com/text/bezgen3.html) eurl} def /interpolate {(http://members.bellatlantic.net/~vze2vrva/design.html) eurl } def /bezmath {(http://www.tinaja.com/text/bezmath.html) eurl } def /table {(http://www.tinaja.com/psutils/imtable.psl) eurl } def } pop % dictionary method << %zzzzz %%%% unused links have been commented for gg9a simplicity /psl (http://www.tinaja.com/psutils/) % dummy temp /psl1 (http://www.tinaja.com/psutils/pdf2bmp.psl) /psl2 (http://www.tinaja.com/psutils/acatdata.psl) /psl3 (http://www.tinaja.com/psutils/catwords.psl) /psl4 (http://www.tinaja.com/psutils/graburls.psl) /psl5 (http://www.tinaja.com/psutils/blender.psl) /psl6 (http://www.tinaja.com/psutils/catools1.psl) /psl7 (http://www.tinaja.com/psutils/strconv.html) /psl8 (http://www.tinaja.com/psutils/bodcat.psl) /psl9 (http://www.tinaja.com/psutils/flatvue1.psl) /psl10 (http://www.tinaja.com/psutils/fern2img.psl) /psl11 (http://www.tinaja.com/psutils/flutools.psl) /psl12 (http://www.tinaja.com/psutils/mscal156q.psl) /psl13 (http://www.tinaja.com/psutils/weblogu2.psl) /psl14 (http://www.tinaja.com/psutils/pfa2pfb.psl) /psl15 (http://www.tinaja.com/psutils/pfb2pfa.psl) /psl16 (http://www.tinaja.com/glib/psdisk03.psl) /psl17 (http://www.tinaja.com/psutils/disktool.psl) /psl18 (http://www.tinaja.com/glib/psinscrt.psl) /psl19 (http://www.tinaja.com/glib/pssearch.psl) /psl20 (http://www.tinaja.com/text/refsum1.html) /psl21 (http://www.tinaja.com/text/reflog1.html) /psl22 (http://www.tinaja.com/psutils/reflog1.psl) /psl23 (http://www.tinaja.com/psutils/refsum1.psl) /psl24 (http://www.tinaja.com/psutils/searepl.psl) /psl25 (http://www.tinaja.com/psutils/weberru2.psl) /psl26 (http://www.tinaja.com/psutils/grabsrch.psl) /psl27 (http://www.tinaja.com/psutils/grabrefs.psl) /magsn01 (http://www.tinaja.com/magsn01.asp) /gonzoutils (http://www.tinaja.com/post01.asp#gonzo) /disktool (http://www.tinaja.com/psutils/disktool.ps) /elesimp (http://www.tinaja.com/glib/elesimp.pdf) /tn5603 (http://partners.adobe.com/asn/developer/pdfs/tn/TN5603.Filters.pdf) /fern2img (http://www.tinaja.com/psutils/fern2img.psl) /fern (http://www.tinaja.com/psutils/fern2img.pdf) /oldfern (http://www.tinaja.com/psutils/fernx1.pdf) /acrosdk (http://partners.adobe.com/asn/developer/acrosdk/main.html) /refman2 (http://partners.adobe.com/asn/developer/pdfs/tn/psrefman.pdf) /refman3 (http://partners.adobe.com/asn/developer/pdfs/tn/PLRM.pdf) /s3011 (http://partners.adobe.com/asn/developer/pdfs/tn/PS3010and3011.Supplement.pdf) /s2011 (http://ftp.ktug.or.kr/obsolete/info/adobe/devtechnotes/pdffiles/ps2011.supplement.pdf) /s2012 (http://ftp.ktug.or.kr/obsolete/info/adobe/devtechnotes/pdffiles/ps2012.supplement.pdf) /s2013 (http://ftp.ktug.or.kr/obsolete/info/adobe/devtechnotes/pdffiles/ps2013.supplement.pdf) /s2014 (http://ftp.ktug.or.kr/obsolete/info/adobe/devtechnotes/pdffiles/ps2014.supplement.pdf) /s2015 (http://ftp.ktug.or.kr/obsolete/info/adobe/devtechnotes/pdffiles/ps2015.supplement.pdf) /s2016 (http://ftp.ktug.or.kr/obsolete/info/adobe/devtechnotes/pdffiles/ps2016.supplement.pdf) /ghost (http://www.cs.wisc.edu/~ghost/) /distlang (http://www.tinaja.com/psutils/distlang.html) /adobepst (http://partners.adobe.com/asn/developer/technotes/) /maildon (mailto:don@tinaja.com) /tinaja (http://www.tinaja.com) /adobe (http://www.adobe.com) /adobesdk (http://partners.adobe.com/asn/developer/acrosdk/main.html) /pstrans (http://www.tinaja.com/glib/pstrans.pdf) /borland (http://www.borland.com/products/downloads/download_cbuilder.html) /ebay (http://cgi6.ebay.com/ws/eBayISAPI.dll?ViewSellersOtherItems&userid=abeja&completed=0&sort=2&since=-1&include=0&page=1&rows=100) /searepl (http://www.tinaja.com/psutils/searepl.psl) /aasdk (http://www.tinaja.com/plugins/AboutAcrobatSDK.api) /uncomp (http://www.tinaja.com/plugins/UncompressPDF.api) /addimage (http://www.tinaja.com/plugins/AddImage.api) /samplejpg (http://www.tinaja.com/plugins/sample.jpg) /transparency (http://www.tinaja.com/plugins/Transparency.api) /threerects (http://www.tinaja.com/plugins/threerects.pdf) /watermark (http://www.tinaja.com/plugins/Watermark.api) /verifyurls (http://www.tinaja.com/plugins/VerifyURLS.api) /flate (http://www.tinaja.com/glib/flatvue.pdf) /pstrans (http://www.tinaja.com/glib/pstrans.pdf) /advt01 (http://www.tinaja.com/advt01.asp) /amlink01 (http://www.tinaja.com/amlink01.asp) /ng1 (news:///comp.text.pdf) /ng2 (news:///comp.lang.postscript) /msc++ (http://msdn.microsoft.com/visualc/productinfo/default.asp) /degub (http://www.tinaja.com/glib/degub.pdf) /ghostscript (http://www.artifex.com/pressreleases/GS70.htm) /demox.psl (http://www.tinaja.com/glib/g9demox.psl) /demox.pdf (http://www.tinaja.com/glib/g9demox.pdf) /demo.pdf (http://www.tinaja.com/glib/g9demo.pdf) /flatvue (http://www.tinaja.com/glib/flatvue.psl) /pdfrefman (http://partners.adobe.com/asn/developer/acrosdk/docs.html) /psrefman (http://partners.adobe.com/asn/developer/technotes/postscript.html) /pdfmrm (http://partners.adobe.com/asn/developer/acrosdk/docs.html) /tipdf (http://partners.adobe.com/asn/developer/acrosdk/docs.html) /asdk (http://partners.adobe.com/asn/developer/acrosdk) /mtcr (http://support.adobe.com/devsup/devsup.nsf/docs/51864.htm) /flatvue1 (http://www.tinaja.com/psutils/flatvue1.psl) /acrob01 (http://www.tinaja.com/acrob01.asp) /post01 (http://www.tinaja.com/post01.asp) /info01 (http://www.tinaja.com/info01.asp) /gurgrm01 (http://www.tinaja.com/gurgrm01.asp) { /tilley (http://www.tilleyfoundation.com) /mnglobal (http://www.mnglobal.com/energy/pg2.htm) /keely (http://www.keelynet.com) /evolve (http://www.evolvedtechnology.com) /hack64 (http://www.tinaja.com/glib/hack64.pdf) /hackar3 (http://www.tinaja.com/glib/hackar3.pdf) /resbn58 (http://www.tinaja.com/glib/resbn58.pdf) /bppt (http://www.batterypoweronline.com) /muse112 (http://www.tinaja.com/glib/muse112.pdf) /muse113 (http://www.tinaja.com/glib/muse113.pdf) /energfun (http://www.tinaja.com/glib/energfun.pdf) /bashpseu (http://www.tinaja.com/glib/bashpseu.pdf) /adobe (http://www.adobe.com) /netscape (http://www.netscape.com) /gallypsl (http://www.tinaja.com/galley1.psl) /gallypdf (http://www.tinaja.com/galley1.pdf) /atn5150 (http://partners.adobe.com/asn/developer/acrosdk/docs/createpdfapi/pdfmarkReference.pdf) /nutour (http://www.tinaja.com/bargains/nutour02.pdf) /nutoursource (http://www.tinaja.com/bargains/nutour02.psl) /bwhistle (http://www.tinaja.com/glib/bwhistle.pdf) /gonzo1 (http://www.tinaja.com/post01.asp#gonzo) /barg01 (http://www.tinaja.com/barg01.asp) /weblib01 (http://www.tinaja.com/weblib01.asp) /gurgrm01 (http://www.tinaja.com/gurgrm01.asp) /z1 (http://www.tinaja.com/bargains/thumb/albradz2.jpg) /z2 (http://www.tinaja.com/bargains/sbtesteq.asp) /z3 (http://www.tinaja.com/images/bargs/albrad02.jpg) /z4 (http://www.tinaja.com/bargains/thumb/tutenaz2.jpg) /z5 (http://www.tinaja.com/bargains/sbphone.asp) /z6 (http://www.tinaja.com/images/bargs/tutena02.jpg) /sourceme (http://www.tinaja.com/glib/gallery.psl) /sourceme2 (http://www.tinaja.com/glib/autourl.psl) } pop >> {mark exch /eurl cvx ] cvx def} forall %%%%%%%%%%%%%%%% New colorizer patches %%%%%%%%%%%%%%%%%% /boxgrays 0.899 def /grayshade boxgrays def /mastergray boxgrays def /staytint {0.33 setgray} def /staytint1 {0.25 setgray} def /showadgrays true def /red {0 settint} def /Zmacro {staytint /ypos ypos 2 add def 72 300 div setlinewidth xpos ypos moveto txtwide 0 rlineto stroke /ypos ypos -2 add def tintoff} def % hair rule /amacro {(zy0) stringmacro /ypos ypos ypara add def 0.33 setgray } def % start drop cap /bmacro {(iFy1) stringmacro /ypos ypos ypara add def black} def % finish drop cap % Gonzo character colorizer /blueon {mark /blue cvx 0.33 /setgray cvx] cvx printlist exch 3 index exch put exch 1 add exch} def /blueoff {mark /beige cvx 0 /setgray cvx] cvx printlist exch 3 index exch put exch 1 add exch} def /tinton {mark 0.33 /setgray cvx] cvx printlist exch 3 index exch put exch 1 add exch} def /tinton1 {mark 0.25 /setgray cvx] cvx printlist exch 3 index exch put exch 1 add exch} def /tinton1b {mark beige cvx % try for aqua after url??? 0.25 /setgray cvx] cvx printlist exch 3 index exch put exch 1 add exch} def /tinton1a {mark /aqua cvx % try for aqua after url??? 0.25 /setgray cvx] cvx printlist exch 3 index exch put exch 1 add exch} def /tinton1p {mark /burple cvx % try for aqua after url??? 0.25 /setgray cvx] cvx printlist exch 3 index exch put exch 1 add exch} def /tinton1r {mark /red cvx % try for aqua after url??? 0.25 /setgray cvx] cvx printlist exch 3 index exch put exch 1 add exch} def /tinton1b {mark /beige cvx % try for beige after url??? 0.25 /setgray cvx] cvx printlist exch 3 index exch put exch 1 add exch} def /tintoff {mark 0 /setgray cvx] cvx printlist exch 3 index exch put exch 1 add exch} def %%%%%%%%%%%%%% COMPACT VERSION OF COLORIZER II %%%%%%%%%%%%%%%%%%%%%% /settint {dup /currenttint exch store 5.999 mul dup floor cvi /&cbar exch store dup floor sub /&cwt exch store [ {/setgray [ /dup cvx 0.3 &cwt 0.59 mul add /ge cvx [1 /exch cvx &cwt 0.59 mul 0.30 add /sub cvx 1 &cwt sub 0.59 mul 0.11 add /div cvx /dup cvx 1 &cwt sub /mul cvx &cwt /add cvx /exch cvx ] cvx [ &cwt 0.59 mul 0.3 add /div cvx /dup cvx &cwt /mul cvx 0] cvx /ifelse cvx /setrgbcolor cvx] cvx /def cvx} {/setgray [/dup cvx 0.59 1 &cwt sub 0.3 mul add /ge cvx [1 &cwt sub 0.3 mul 0.59 add /sub cvx &cwt 0.3 mul 0.11 add /div cvx /dup cvx &cwt /mul cvx 1 &cwt sub /add cvx /exch cvx 1 /exch cvx] cvx [1 &cwt sub 0.3 mul 0.59 add /div cvx /dup cvx 1 &cwt sub /mul cvx /exch cvx 0] cvx /ifelse cvx /setrgbcolor cvx] cvx /def cvx} {/setgray [/dup cvx 0.59 &cwt 0.11 mul add /ge cvx [&cwt 0.11 mul 0.59 add /sub cvx 1 &cwt sub 0.11 mul 0.30 add /div cvx /dup cvx 1 &cwt sub /mul cvx &cwt /add cvx 1 /exch cvx] cvx [0 /exch cvx &cwt 0.11 mul 0.59 add /div cvx /dup cvx &cwt /mul cvx] cvx /ifelse cvx /setrgbcolor cvx] cvx /def cvx} {/setgray [/dup cvx 0.59 1 &cwt sub mul 0.11 add /ge cvx [1 &cwt sub 0.59 mul 0.11 add /sub cvx &cwt 0.59 mul 0.30 add /div cvx /dup cvx &cwt /mul cvx 1 &cwt sub /add cvx 1] cvx [0 /exch cvx 1 &cwt sub 0.59 mul 0.11 add /div cvx /dup cvx 1 &cwt sub /mul cvx /exch cvx] cvx /ifelse cvx /setrgbcolor cvx] cvx /def cvx} {/setgray [/dup cvx 0.11 &cwt 0.30 mul add /ge cvx[&cwt 0.30 mul 0.11 add /sub cvx 1 &cwt sub 0.30 mul 0.59 add /div cvx /dup cvx 1 &cwt sub /mul cvx &cwt /add cvx /exch cvx 1] cvx [ &cwt 0.30 mul 0.11 add /div cvx /dup cvx &cwt /mul cvx /exch cvx 0 /exch cvx ] cvx /ifelse cvx /setrgbcolor cvx ] cvx /def cvx} {/setgray [ /dup cvx 0.30 1 &cwt sub 0.11 mul add /ge cvx[ 1 /exch cvx 1 &cwt sub 0.11 mul 0.30 add /sub cvx &cwt 0.11 mul 0.59 add /div cvx /dup cvx &cwt /mul cvx 1 &cwt sub /add cvx ] cvx [ 1 &cwt sub 0.11 mul 0.30 add /div cvx /dup cvx 1 &cwt sub /mul cvx 0 /exch cvx] cvx /ifelse cvx /setrgbcolor cvx ] cvx /def cvx} ] &cbar get exec exec} bind def /beige {0.10 settint} def % examples of convenience operators /aqua {0.52 settint} def /blue {0.67 settint} def /lime {0.44 settint} def /burple {0.75 settint} def %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% /guru { gonzo begin ps.util.1 begin printerror nuisance begin} def % guru % activate gonzo utilities 50 50 10 setgrid % create grid % 56 61 showgrid /setpagefonts { /cstretch 0.015 def /sstretch 0.015 def /font0 /StoneSans-Bold 1.6 gonzofont /font1 /StoneSans 0.95 gonzofont /font2 /StoneSans [0.95 0 0.25 0.95 0 0 ] gonzofont /font4 /StoneSans 0.85 gonzofont /font3 /StoneSans-Bold 0.85 gonzofont /font6 /StoneSans-Bold 0.85 gonzofont /font7 /StoneSans-Bold 1.05 gonzofont % subheaders /font8 /StoneSans-Bold [0.65 0 0 0.65 0 0.4] gonzofont /txtwide 36 store /yinc 1.2 store /kern 0.1 store /pm 1.5 store aqua 0.33 setgray font1 black /amacro { mark /aqua cvx 0.33 /setgray cvx ] cvx printlist exch 3 index exch % stuff into gonzo printlist put exch 1 add exch } def /bmacro { mark /black cvx ] cvx printlist exch 3 index exch % stuff into gonzo printlist put exch 1 add exch } def /shiftin {xpos /xposhold exch store /xpos xpos 3 add store} def /shiftout {/xpos xposhold store} def /texttop 51 store /textleft 3 store /cmacro {aqua 0.25 setgray (znhL7) stringmacro /xpos xpos 1.7 sub store /ypos ypos .1 sub def } def % left title /dmacro {black (pL1hz) stringmacro /xpos xpos 1.7 add store /ypos ypos .1 add def} def % normal text after centered title /fmacro % try and fake | {mark /gsave cvx /currentpoint cvx /moveto cvx 0.1 /setlinewidth cvx 0 0.65 /rlineto cvx /stroke cvx /grestore cvx ] cvx printlist exch 3 index exch put % stuff into gonzo printlist exch 1 add exch % increment gonzo list count } def } def setpagefonts % -2 50.5 (optional header here \274) cl %% Set document opening conventions. Note DOCVIEW limited. [/CropBox [0 0 520 620] % set the wierd size /PAGES pdfmark [ {Catalog} << /ViewerPreferences << /FitWindow true /CenterWindow true >> /PageLayout /OneColumn % continous /Pagemode /UseNone % no thumbs /View [/XYZ null null 1 ] % force 100% >> /PUT pdfmark %%%%%%%%%%%%%%%%% START DEMO ART (not in use) %%%%%%%%%%%%%%%% %%% Hand patching Info: % next available variable is /GS3 % transparency gstate is object 2 % contents stream is object 18 gets q /GS3 gs (xstuff) Q % be sure to q Q bracket to localize % resources stream is object 19 gets /GS3 2 0 R /transoverlay { % make a new graphics state [ /_objdef {newgsstate} /type /dict /OBJ pdfmark % fill the new overlay graphics state - See PDF manual for details [ {newgsstate} << /Type /ExtGState /ca 0.5 % fill transparency is 0.5 /CA 0.5 % stroke transparency is 0.5 /BM /Normal /AIS false /OP false /OPM 1 /op true >> /PUT pdfmark % start a Begin Picture graphics overlay subroutine... [ /BBox [0 0 1000 1000 ] /_objdef {overlaypix} /BP pdfmark % fill the Begin Picture graphics overlay Xobject subroutine... 0 0.5 1 setrgbcolor % on the aqua side of blue 4 4 6 6 rectfill % complete the Begin Picture graphics overlay Xobject... [ /EP pdfmark } def % Write a two squares program... /twosquares { gsave translate 1 0.5 0 setrgbcolor % red side of orange 2 2 6 6 rectfill % do background opaque box [ {overlaypix} /SP pdfmark % show foreground transparent box grestore} def % Distill the two squares program. Initially use a BARE Distiller Job % Options that has no compression, no embedded fonts, and little else save /snap1 exch store %%% transoverlay % create new objects %%% 14 17.5 twosquares snap1 restore %%%%%%%%%%%% END DEMO %%%%%%% /burpwide 29.5 store /burplebox3 {save /burp1 exch store xpos ypos translate -1 .2 mt 3.5 yinc mul .4 add pd burpwide pr 3.5 yinc mul .4 add pu closepath 0.9 setgray fill burp1 restore } def /burplebox2 {save /burp1 exch store xpos ypos translate -1 .2 mt 2.5 yinc mul .4 add pd burpwide pr 2.5 yinc mul .4 add pu closepath 0.9 setgray fill burp1 restore } def /burplebox2.5 {save /burp1 exch store xpos ypos translate -1 .2 mt 3 yinc mul .4 add pd burpwide pr 3 yinc mul .4 add pu closepath 0.9 setgray fill burp1 restore } def /burplebox4 {save /burp1 exch store xpos ypos translate -1 .2 mt 4.5 yinc mul .4 add pd burpwide pr 4.5 yinc mul .4 add pu closepath 0.9 setgray fill burp1 restore } def /burplebox5 {save /burp1 exch store xpos ypos translate -1 .2 mt 5.5 yinc mul .4 add pd burpwide pr 5.5 yinc mul .4 add pu closepath 0.9 setgray fill burp1 restore } def /burplebox6 {save /burp1 exch store xpos ypos translate -1 .2 mt 6.5 yinc mul .4 add pd burpwide pr 6.5 yinc mul .4 add pu closepath 0.9 setgray fill burp1 restore } def /burplebox7.5 {save /burp1 exch store xpos ypos translate -1 .2 mt 8 yinc mul .4 add pd burpwide pr 8 yinc mul .4 add pu closepath 0.9 setgray fill burp1 restore } def /burplebox8 {save /burp1 exch store xpos ypos translate -1 .2 mt 8.5 yinc mul .4 add pd burpwide pr 8.5 yinc mul .4 add pu closepath 0.9 setgray fill burp1 restore } def /burplebox9 {save /burp1 exch store xpos ypos translate -1 .2 mt 9.5 yinc mul .4 add pd burpwide pr 9.5 yinc mul .4 add pu closepath 0.9 setgray fill burp1 restore } def /burplebox20 {save /burp1 exch store xpos ypos translate -1 .2 mt 20.5 yinc mul .4 add pd burpwide pr 20.5 yinc mul .4 add pu closepath 0.9 setgray fill burp1 restore } def /pagenum 1 store /startnewpage { black beige 0.35 setgray 21 -2.5 (|3\320|j) pagenum 10 string cvs mergestr (|j\320) mergestr cc aqua showpage %% start next page /pagenum pagenum 1 add store 50 50 10 setgrid % create grid setpagefonts font1 textleft texttop } def /su {surl font6} store /to {tinton1 font6} store /tx {tintoff font1} store /tabs [11 15] store aqua 0.33 setgray font0 20 47.3 0.7 add 1 sub (Some PostScript Disk Access Notes) cc % 20 45.3 0.7 add (Search & Replace Utility) cc black font2 textleft 43 0.3 add % this one only need |h below (|3Don Lancaster Synergetics, Box 809, Thatcher, AZ 85552 copyright c2002 as |/surl |6GuruGram|1|/gurgrm01 |6#13 |/surl http://www.tinaja.com|/tinaja |/surl don@tinaja.com|/maildon (928) 428-4073 |a|0T|b|1|k|khe general purpose |/surl |6PostScript|1|/post01 computing language from |/surl |6Adobe Systems|1|/adobe has a number of different disk access features. These include support of high end printers and typesetters that have internal hard drives for font, page, job, and form storage. And the ability for |/surl |6Acrobat Distiller|1|/acrob01 to access and modify files on its own host operating system. |h In expanding upon an |/surl |6InfoPack|1|/info01 I did for a client, I thought I'd gather together and review some of the more obscure PostScript disk access fundamentals. |c Essential PostScript Resources |d Two "must have" documents are the |/surl |6PostScript II Reference Manual|1|/refman2 and the |/surl |6PostScript III Reference Manual|1|/refman3 . These are downloadable free using these links, or may be purchased in hard copy via |/surl |6Amazon Books|1|/amlink01 . |h The more interesting and more obscure disk access info usually appears in the PostScript Language supplements\274 |6|/shiftin |/staytint1 |/burplebox7.5 |/surl PostScript Language Supplement 2011|/s2011 |/surl PostScript Language Supplement 2012|/s2012 |/surl PostScript Language Supplement 2013|/s2013 |/surl PostScript Language Supplement 2014|/s2014 |/surl PostScript Language Supplement 2015|/s2015 |/surl PostScript Language Supplement 2016|/s2016 |h |/surl PostScript Language Supplements 3011 and 3012|/s3011 |1|/shiftout |/aqua |/black Additional PostScript support appears on this |/surl |6Adobe PostScript Technotes|1|/adobepst site, on my |/surl |6PostScript Libray|1|/post01 and |/surl |6Acrobat Library|1|/acrob01 pages, my earlier |/surl |6PostScript Disk|/disktool |/surl File Utilities|1|/disktool utility file and by way of either the |/surl |6comp.lang.postscript|1|/ng1 or the |/surl |6comp.text.pdf|1|/ng2 usenet newsgroups. |h A collection of third party links can also be found |/surl |6here|1|/post01 and |/surl |6here|1|/acrob01 . ) cl startnewpage (|c Snooping Around |d The PostScript language is fairly open and inspectable, so it is often a good idea to snoop around inside to find the available resources. But note that\274 |h|/red |6|/shiftin |/staytint1 You must have two way comm to return any useful info from a PostScript peripheral, printer, or imagesetter!|1 |h|1|/shiftout |/aqua |/black Many early PostScript peripherals were conventional parallel port driven and thus unable to return any info or messages. To intelligently work with PostScript these days, you |/tinton1 |6must|1|/tintoff use both two-way comm and software capable of receiving and interpreting returned info. |h Suitable two-way comm methods include serial, USB, SCSI, Ethernet, AppleTalk, new IEEE high speed bidirectional parallel, or IDE. To make sure you have two-way comm, just send your middle name to your PostScript device. You should get back an |/tinton1 |6undefined|1|/tintoff error message or log file. |h The host based |/surl |6Acrobat Distiller|1|/acrob01 , of course, eliminates any comm hassles and lets you directly run interpreted PostScript without comm worries. As found in this |/surl |6Using Acrobat Distiller as a General Purpose PostScript Computer|1|/distlang tutorial. |h Your essential starting point on any PostScript snoop is the |/tinton1 |6version|1|/tintoff command. This should tell you whether you are working with PostScript Level I, II, or II, with |/surl |6GhostScript|1|/ghost , or with a third tier clone. A "real" level two PS device should return something like |/tinton1 |62014|1|/tintoff , while a level three will use a fancier |/tinton1 |63010.157|1|/tintoff . |h Once you know your version, you can dump and save both your |/tinton1 |6systemdict|1|/tintoff and |/tinton1 |6statusdict|1|/tintoff dictionaries\271 |6|/shiftin |/burple |/staytint1 |/burplebox2.5 statusdict|j|j begin |j|jstatusdict |j|j{exch == == (|j\\\\n|j) print } forall |h systemdict begin systemdict {exch == == (|j\\\\n|j) print } forall |1|/shiftout |/aqua |/black There are bunches of other dictionaries which you should be able to "avalanche" out of |/tinton1 |6systemdict|1|/tintoff . One "magical" dictionary is |/tinton1 |6internaldict|1|/tintoff which does need an easily found password and special treatment\274 |6|/shiftin |/burple |/staytint1 |/burplebox2 1183615869 internaldict begin 1183615869 internaldict {exch == == (|j\\\\n|j) print } forall |1|/shiftout |/aqua |/black One of the more interesting commands buried in |/tinton1 |6internaldict|1|/tintoff is |/tinton1 |6superexec|1|/tintoff , which sometimes lets you access restricted info\274 |6|/shiftin |/burple |/staytint1 |/burplebox2 1183615869 internaldict begin {restricted stuff {access proc} forall} superexec |1|/shiftout |/aqua |/black ) cl startnewpage (|c IODevices and File Systems |d In general, there are two main types of disk files associated with PostScript or Acrobat access. |h Files |/tinton1 |6internal|1|/tintoff to an imagesetter or a high end printer will often make use of the |/tinton1 |6Adobe File System|1|/tintoff format and consist or an UNIX-like collection of 1024 byte pages. The first disk is typically called |/tinton1 |6(%disk0%)|1|/tintoff , but oddball names are sometimes substituted. A |/to (%*)|/tx can often be used as an "any disk" wildcard. As we'll shortly see, these files are easily created, read, written, and cataloged. |h |/surl |6Adobe Acrobat|1|/acrob01 instead accesses whatever the |/tinton1 |6(%os%)|1|/tintoff host operating system happens to be using. While you can usually create, read, and write files to the host system, I have been unable to find any means of cataloging host system files with Acrobat. Nor of finding used and available disk space. Nor of using relative filenames. Apparently these restrictions may have been purposely done to reduce virus and other malicious file potential. |h Typically, PostScript or Acrobat will link |/to IODevices|/tx of one sort or another. Some of these will be |/to FileSystem|/tx devices that can have files created, read, written, or deleted. FileSystem devices can sometimes be initialized, sized, or cataloged. |h With PostScript III, you can list your |/to IODevices|/tx with\274 |3|/shiftin |/burple |/staytint1 |/burplebox2 /str 50 string def (*){==} str /IODevice resourceforall |1|/shiftout |/aqua |/black Doing so may return this list for Distiller\274 |3|/shiftin |/aqua |/staytint1 |/burplebox6 (%hostfont%) (%Distillery%) (%os%) (%fontset%) (%cid%) (%ram%) |1|/shiftout |/aqua |/black The properties of each of these |/to IODevices|/tx can be found by using\274 |3|/shiftin |/burple |/staytint1 |/burplebox2 (%hostfont%)currentdevparams {exch 50 string cvs print ( ) print == } forall (\\\\n) print |1|/shiftout |/aqua |/black \274 which should tell us that |/to (%Distillery%)|/tx is a |/to Communications|/tx IODevice, while all the others are |/to FileSystem|/tx IODevices. Writeable and readable disks would be included as FileSystem devices. Similar code can be used to find the available Disk Systems for most any PostScript printer or imagesetter. ) cl startnewpage (|c Level II Disk Commands |d There are only six PostScript level II disk commands of primary interest. They may apply only to |/to Adobe File System|/tx format devices. These have been retained in level III as compatibility operators\274 |/to devstatus \320|/tx |t|2string |/to devstatus|/tx |2searchable writeable hasNames |tmounted removable searchOrder free logicalSize |ttrue (if device known) false (if not) |h|1 Returns the values of various file system attributes for the disk device identified by string (which must be |/to %diskn%|/tx for some integer value of n). If the specified device name is known, the boolean value true is returned on the top of the stack, accompanied by the values of the device parameters Searchable, Writeable, HasNames, Mounted, Removable, SearchOrder, Free, and LogicalSize If the device name is unknown, only the value false is returned on the stack. |h Errors: |/to stackoverflow, stackunderflow, typecheck|tx |/to diskonline \320|/tx |t|/to diskonline|/tx |2 bool |1(statusdict dictionary)|1 |h Returns a boolean value indicating whether there exists a writeable disk device. The result will be true if there exists a device parameter set named |/to %diskn%|/tx (for some integer value of n) in which the value of the Writeable parameter is true; if no such parameter set exists, a false value will be returned. Disk does not need an initialized file system. |h Errors: |/to stackoverflow|/tx |/to diskstatus \320|/tx |t|/to diskstatus|/tx |2free total |1(statusdict dictionary) |h Returns the current number of free blocks and the total number of blocks available on all writeable disk devices. These values are determined by finding all known device parameter sets named |/to %diskn%|/tx (for integer values of n) in which the value of the Writeable parameter is true, and totaling the values of their Free and LogicalSize parameters, respectively. |h Errors: |/to stackoverflow|tx |/to initializedisk \320|/tx |t|2blocks action |/to initializedisk|/tx |1(statusdict dictionary) |h Initializes each writeable disk by setting the device parameters LogicalSize and InitializeAction in each |/to %diskn%|/tx parameter set to the values blocks and action + 1, respectively. This operator should be invoked only from within a system administrator job. |h Errors: |/to invalidaccess, ioerror, rangecheck, stackunderflow, typecheck|/tx ) cl startnewpage (|/to setuserdiskpercent |\320|/tx |t|2int |/to setuserdiskpercent|/tx (statusdict dictionary) |h Formerly set the percentage of disk space reserved for user files. This operator now pops the operand int off the stack and otherwise does nothing. This operator should be invoked only from within a system administrator job. There is no Language Level 2 equivalent for this operator. |h Errors: |/to invalidaccess, rangecheck, stackunderflow, typecheck|tx |/to userdiskpercent |\320|/tx |t|/to userdiskpercent|/tx |2 int |1 (statusdict dictionary) |h Formerly returned the percentage of disk space reserved for user files. This operator now does nothing and returns the value 0. There is no LanguageLevel 2 equivalent for this operator. |h Errors: |/to stackoverflow|/tx |c Level III Disk Parameters |d PostScript Level III instead uses resource dictionaries that can be expanded for future capabilities. In the listings that follow, read-only refers only to access by language operators (for example, |/to setdevparams|/tx and |/to currentdevparams|/tx ). |h The value of a read-only parameter can change, but not as a result of invoking |/to setdevparams|/tx . Changes to parameters in FileSystem parameter sets take effect immediately. |h Device parameters in the |/to %diskn%|/tx parameter set: |/to Type|/tx |2name|1 (Read-only) |t|tThe parameter set type; must be |/to FileSystem|/tx . |/to Bus|/tx |2string|1 (Read-only)|t|tThe name of the bus on which this disk resides |t|t|/to %Scsi%|/tx (or |/to%ScsiX%|tx ) if a SCSI bus, |/to %Ide%|/tx |t|t(or |/to %IdeX%|/tx ) if an IDE bus. If the imaging |t|tsystem uses a file system of the native |t|toperating system rather than the Adobe storage |t|tdevice implementation, this parameter may not |t|tbe meaningful or may be absent. More info |t|tabout the bus (for this disk device) can be |t|tobtained by using |/to currentdevparams|/tx . |/to HasNames|/tx |2boolean|1 (Read-only) |t|tA flag specifying whether the device supports |t|tnamed files. Since a device will not mount |t|tsuccessfully unless it contains a valid file system, |t|t|/to HasNames|/tx is always true for mounted devices; |t|tif false, the device is not mounted. ) cl startnewpage (|/to Mounted|/tx |2boolean|1 |t|tA flag specifying whether the device should be |t|tmounted or dismounted, or (if queried) |t|twhether the device is currently mounted. |t|tSetting |/to Mounted|/tx to true indicates that the |t|tsystem should attempt to mount the device, |t|tand setting it to false that it should |t|tattempt to dismount the device. |h |t|tMounting a device makes it known to the |t|tsystem and makes it at least readable, |t|tdepending on the nature of the device. A |t|tdevice will not mount successfully unless |t|tit contains a valid file system (that is, |t|tunless the |/to HasName|/tx parameter is true). If an |t|tattempted mount (or dismount) fails, a |t|t|/to configurationerror|/tx occurs. |h |t|tWhen queried, the value of this parameter |t|tindicates whether the device is currently |t|tmounted. Mounted should be queried |t|timmediately after it is set, to obtain the |t|tattempted mount or dismount result. |/to Removable|/tx |2boolean|1 (Read-only) |h |t|tA flag specifying whether the device supports |t|tremovable media. Depending on how the |t|tremovable media device operates, setting |t|tthe value of |/to Mounted|/tx to false for such |t|ta device will either eject the medium or |t|tallow the medium to be removed. Once the |t|tmedium has been removed, the device cannot |t|tbe mounted until the medium is reinserted. |/to Writeable|/tx |2boolean|1 (Read-only except during a mount) |h |t|tA flag specifying whether the files on the device |t|tcan be opened for write access (or, if the |t|tdevice is not mounted, whether the device will |t|tsupport writeable media). If the medium is |t|twriteprotected, |/to Writeable|/tx is false. This |t|tparameter can be set only during a mount- |t|tthat is, at the same time that the Mounted |t|tparameter is being set to read only if the |t|tmedium is not write-protected. ) cl startnewpage (|/to Searchable|/tx |2boolean|1 |t|tA flag specifying whether the device |t|tparticipates in searches for a file when a file |t|tname is supplied that does not specify a device |t|t(see PLR3, Section 3.8.2). |h |t|tNote: On some products, devices that support |t|tremovable media will initially have |/to Searchable|/tx |t|tset to false. |/to Searchable|/tx must be explicitly set |t|tto true on such devices to enable them to |t|tparticipate in device searches. |/to SearchOrder|/tx |2integer|1 |t|tThe priority (0 or greater) at which the device |t|tparticipates in file searches as indicated by a |t|tvalue of true for the |/to Searchable|/tx parameter. |t|tThe lower the value, the higher the priority. |t|tThis parameter is ignored if |/to Searchable|/tx is false. |/to BlockSize|/tx |2integer|1 (Read-only) |t|tNumber of bytes in a block on the formatted |t|tdevice. For a disk using the Adobe file system, |t|t|/to BlockSize|/tx is 1024. This parameter determines |t|tthe unit for the values of the |/to Free|/tx , |t|t|/to PhysicalSize|/tx , and |/to LogicalSize|/tx parameters. |/to Free|/tx |2integer|1 (Read-only) |t|tNumber of blocks of free space available |t|ton the medium in the device (where the block |t|tsize is indicated by the |/to BlockSize|/tx parameter). |t|tFree is 0 if the medium is completely full or |t|tif the device is not mounted. |/to PhysicalSize|/tx |2integer|1 (Read-only) |t|tThe number of blocks of medium in the device |t|t(where the block size is indicated by the |t|t|/to BlockSize|/tx parameter). This is the |t|tmaximum allowable size of the file system; |t|tthe exact size is determined by the |/to LogicalSize|/tx . |h |t|t|/to PhysicalSize|/tx is 0 if the device is not mounted. |/to LogicalSize|/tx |2integer|1 |t|tThe number of blocks allocated to the file |t|tsystem (where the block size is indicated by the |t|t|/to BlockSize|/tx value). When queried, |/to LogicalSize|/tx |t|tis 0 if the device is not mounted. When set, this |t|tparameter specifies the number of blocks to be |t|tallocated to the file system when it is created in |t|tresponse to the |/to InitializeAction|/tx parameter. ) cl startnewpage ( |t|tThe value of |/to LogicalSize|/tx must not exceed that |t|tof |/to PhysicalSize|/tx . If |/to LogicalSize|/tx is 0, then |t|t|/to InitializeAction|/tx uses a default size that is |t|tnormally the same as the value of |/to PhysicalSize|/tx . |h |t|tIf |/to LogicalSize|/tx is set with a certain value and (as |t|tspecified by the value of |/to InitializeAction|/tx ), |t|tthe medium in the device is reformatted before |t|tthe file system is created, a subsequent query of |t|t|/to LogicalSize|/tx should return the value that was |t|tset. However, if |/to LogicalSize|/tx is queried before |t|tthe medium is reformatted, it may return the |t|tcurrent size instead. |/to InitializeAction|/tx |2integer|1 |t|tA code specifying an action for initializing the |t|tdevice: |h |t|t|/to 0 \320 No action.|/tx This value is returned when the |t|tparameter is queried. |h |t|t|/to 1 \320 Deletes current file system.|/tx (if any) and |t|tcreates one having the size specified by the |t|t|/to LogicalSize|/tx parameter. (Medium is assumed |t|tto have been formatted already.) The device |t|tmust first be mounted; otherwise, an |/to ioerror|/tx |t|twill occur. |h |t|t|/to 2 \320 Reformats entire medium|/tx before creating |t|ta new file system of size |/to LogicalSize|/tx . The |t|t|/to Interleave|/tx parameter also plays a role in how |t|tthe medium is formatted. |h |t|t|/to 3+ \320 Same effect as the value 2|/tx and also |t|tcarries out product dependent actions, which |t|ttypically consist of preformatting the disk |t|tand running integrity tests before creating |t|tthe file system. Some devices can have |t|tadditional parameters that serve as arguments |t|tto |/to InitializeAction|/tx . |/to Interleave|/tx |2 integer|1 |t|tThe interleave number, n, specifying n-to-1 |t|tinterleaving. Interleaving arranges logically |t|tcontiguous sectors on the disk in the most |t|tefficient way for the system using that disk. |t|tThis parameter is used only when the medium |t|tis being formatted by |/to InitializeAction|/tx . ) cl startnewpage ( |t|tFor example, assume there are 16 sectors going |t|taround a single track on a disk. If the first |t|tsector is logical sector number 1, the second 2, |t|tthe third 3, etc\274 the value of |/to Interleave|/tx |t|tis 1 (1-to-1 interleaving). In this case, the |t|tsystem must be very fast to be able to take data |t|tfrom the disk, one sector immediately after |t|tanother. If the system fails to consume the first |t|tsector in time for the second sector, it has to |t|twait an entire revolution of the disk to get the |t|tnext sector. This can result in very poor |t|tperformance. |h |t|tIf the first sector is logical sector number 1, |t|tthe third 2, the fifth 3, and so on, the system |t|tneeds to consume the current sector while |t|tthe head skips over a sector in time for the next |t|tlogical sector. In this case, the value of |t|t|/to Interleave|/tx is 2 (2-to-1 interleaving). The sectors |t|tin between are used for higher logical numbers. |t|tIt takes a minimum of two revolutions to get |t|tthe data for an entire track off the disk. In |t|tthis example, the second physical sector on the |t|tdisk would be between logical sectors 1 and 2, |t|tand would be logical sector 9. |h |t|tSimilarly, with an Interleave value of 3, the first |t|tsector is logical sector number 1, the fourth 2, |t|tand so on. |h |t|tNormally, Interleave gets set to a value that |t|tlets the software use the data during the time |t|tbetween sectors, but not waste any time. It is |t|tdifficult to determine what the proper value is. |t|tThe value depends greatly on the job accessing |t|tthe disk. For drives that provide buffering for |t|ta full track of data, 1-to-1 interleaving is |t|talmost always most efficient. |/to PrepareAction|/tx |2 integer|1 |t|tAn action to prepare the underlying |t|tfile system for a specific purpose: |h |t|t|/to 0 \320 No action|/tx . |h |t|t|/to 0 \320 Device specific action|/tx . ) cl startnewpage (|c Some Examples |d Here are a few simple examples of PostScript disk access routines. In a fully blown program, you'll want to add such bells and whistles as a conditional |/to known|/tx command to prevent errors should the commands not be available. |h But first, an important rule\274 |h|/red |/staytint1 |/shiftin |6Always use a "\\\\\\\\" double reverse slash inside a filename or other PostScript string every time you really want a "\\\\" or single reverse slash! |/aqua |/black |/shiftout |1 Things can really get complicated in |/su Gonzo|1|/gonzoutils where you'll need |/to four|/tx reverse slashes for every one that is to actually appear on your screen or page. |/to Merge two strings\274|/tx This routine is excerpted from my |/su PostScript Gonzo Utilities|1|/gonzoutils that are found on the |/su PostScript Library|1|/post01 page. It is quite handy when manipulating filenames and such. The two top stack strings become one\274 |6|/shiftin |/burple |/staytint1 |/burplebox3 /mergestr {2 copy length exch length add string dup dup 4 3 roll 4 index length exch putinterval 3 1 roll exch 0 exch putinterval} def |1|/shiftout |/aqua |/black |/to Check available AFS disk space \320 |/tx Should work for most PostScript printers and imagesetters using the Adobe File System format\274 |6|/shiftin |/burple |/staytint1 |/burplebox3 statusdict begin diskonline dup == flush true {diskstatus == == flush} if end |1|/shiftout |/aqua |/black This (and similar routines) may or may not work for Distiller |/to (%os%)|/tx disk operating systems, depending on the presence or absence of |/to PhysicalSize|/tx and |/to Free|/tx parameters. Possible workarounds may be available through the |/su Acrobat|/acrosdk |/surl SDK Software Development Kit|1|/acrosdk . |/to Catalog AFS disk \320 |/tx Disks are normally named |/to (%disk1%)|/tx , |/to (%disk2%)|/tx , etc\274 . A |/to (%*)|/tx can usually be used as a wildcard\274 |6|/shiftin |/burple |/staytint1 |/burplebox2 /str 50 string def (%*){== } str filenameforall |1|/shiftout |/aqua |/black On Distiller using |/to (%os%)|/tx disk operating systems, this code may sometimes only return a fontlist found in |/to (%hostfont%)|/tx . ) cl startnewpage (|/to Write to an AFS disk using currentfile \320 |/tx Rename and |/to prepend|/tx the following to any text file to be stored on a laser printer's hard disk... |6|/shiftin |/burple |/staytint1 |/burplebox8 /filename (filenamehere) def filename status {4 {pop} repeat filename deletefile} if /mfn filename (w) file def /buffer 1024 string def /bf {{currentfile buffer readstring pop dup length 0 eq {pop mfn closefile exit}{mfn exch writestring}ifelse } loop}def bf |1|/shiftout |/aqua |/black Once again, double reverse slashes should be used in any PostScript string where a single reverse slash is wanted. |/to Prepare file for Distiller host disk read or write \320 |/tx This also shows how to use our |/to mergestr|1|/tx utility\274 |6|/shiftin |/burple |/staytint1 |/burplebox9 /diskfileheader (C:\\\\\\\\WINDOWS\\\\\\\\Desktop\\\\\\\\inherit) store /diskfilesourcename (g9demoyx.pdf) store /diskfiletargetname (g9demozz.pdf) store /sourcefilename diskfileheader diskfilesourcename mergestr store /targetfilename diskfileheader diskfiletargetname mergestr store /readfile sourcefilename (r) file store /writefile targetfilename (w+) file store |1|/shiftout |/aqua |/black Note that the (w+) tells us to |/tinton1 |6append|1|/tintoff file info, rather than overwriting it. You can use similar code to read or write AFS files by changing to the |/to (%disk1%)|/tx filename scheme. |/to Read a file one byte at a time \320 |/tx After you predefine a |/to /yourreadfilename|/tx to either AFS or |/to (%os%)|/tx naming conventions\274 |6|/shiftin |/burple |/staytint1 |/burplebox6 /strx (X) def /yourreadfilename (r) file /myworkfile exch def {myworkfile read {strx exch 0 exch put your_character_user_routine_goes_here } {myworkfile closefile exit} ifelse } loop |1|/shiftout |/aqua |/black The |/to your_character_user_routine|/tx must consume a one character stack-top string in some manner. ) cl startnewpage (|/to Read a file one line at a time \320 |/tx After you predefine a |/to /yourreadfilename|/tx to either AFS or |/to (%os%)|/tx naming conventions\274 |6|/shiftin |/burple |/staytint1 |/burplebox6 /strx 256 string def yourreadfilename (r) file /myworkfile exch def {myworkfile strx readline {your_string_user_routine_goes_here} {myworkfile closefile exit} ifelse } loop |1|/shiftout |/aqua |/black The |/to your_character_user_routine|/tx must consume a one line stack-top string in some manner. |/to /strx|/tx can be lengthened or shortened as needed. It must be larger than the longest line in the file. |/to Change the position of the next file read or write \320 |/tx After |/to myworkfile|/tx is predefined and in use\274 |6|/shiftin |/burple |/staytint1 |/burplebox2 /nextfileloc 12345 def myworkfile nextfileloc setfileposition |1|/shiftout |/aqua |/black This scheme lets you randomly access file info. Rather than sequentially. |c Strings as "Disk" Files |d PostScript strings can be made to appear as read or write files by applying suitable filters to them. This lets you use many of the disk file commands for string manipulation. The only major restriction is that your strings will have the usual 65,536 character limit. |h The two magic filters are\274 |/to NullEncode \320|/tx |t|2source|1 |/to NullEncode|/tx |2 filter|1 |h Passes all data through, without any modification. This permits an arbitrary data target (procedure or string) to be treated as an output file. |/to SubFileDecode \320|/tx |t|2source count string |/to SubFileDecode|/tx filter |h Passes all data through, without any modification. This permits an arbitrary data source (procedure or string) to be treated as an input file. Optionally, this filter detects an end-of-data marker in the source data stream, treating the preceding data as a subfile. |h |/to source|/tx is the original string. |/to count|/tx is the maximum number of characters to be delivered. |/to string|/tx is an end of file marker, such as a carriage return or tab character. ) cl startnewpage (Here's a sneaky example that shows you the power of strings-as-files\274 |/to Convert an array to a string \320 |/tx A stacktop array of 8-bit integers can get converted to a string using this code\274 |6|/shiftin |/burple |/staytint1 |/burplebox2 /makestring {dup length string dup /NullEncode filter 3 -1 roll {1 index exch write} forall pop} def |1|/shiftout |/aqua |/black While file techniques are certainly not needed here, their |/su Elegant Simplicity|1|/elesimp makes for a very cute routine. |h Our PostScript |/su Fractal Fern|1|/fern gives you a second example of string-as-file manipulations. Per this |/su FERN2IMG.PSL|1|/fern2img sourcecode. The same utility can be used to convert most any calculation-intensive PostScript routine into a fixed size bitmap image. Giving you a much faster print or view time at the expense of fixed size and resolution. Here's the calculated fern for a |/su speedup comparison|1|/oldfern . |h More PostScript utilities appear on our |/su PostScript Library|1|/post01 page. Additional string-as-file resources appear in |/su Adobe Tech Note TN5603|1|/tn5603 |h |c Some More Detailed Applicatons |d Here's a list of some of our other PostScript disk manipulation files\274 |6|/shiftin |/staytint1 |/burplebox20 |/su pdf2bmp.psl|1|/psl1 |tAcrobat Bitmap Typewriter |/su acatdata.psl|1|/psl2 |tAcrobat Catalog Internal Data Formats |/su catwords.psl|1|/psl3 |tAcrobat Catalog Word List Extractor |/su graburls.psl|1|/psl4 |tAcrobat URL Extractor & Link Tester |/su blender.psl|1|/psl5 |tBitmap blender and manipulator |/su catools1.psl|1|/psl6 |tCatalog Data Manipulation Tools |/su strconv.html|1|/psl7 |tConvert PS Strings, Integers & Arrays |/su bodcat.psl|1|/psl8 |tDuplex Catalog Auto-Addresser |/su flatvue1.psl|1|/psl9 |tFlate Compression Object File Viewer |/su fern2img.psl|1|/psl10 |tFractal Fern to Image Converter |/su flutools.psl|1|/psl11 |tFlutterwumper Utilities |/su mscal156q.psl|1|/psl12 |tFourier Equation Generator (plus more |/tintoff |t in the |/su Magic Sinewave|1|/magsn01 library) |/su weblogu2.psl|1|/psl13 |tLog File Interpreter Utilities |/su pfa2pfb.psl|1|/psl14 |tPFA to PFB Font File Converter |/su pfb2pfa.psl|1|/psl15 |tPFB to PFA Font File Converter |/su psdisk03.psl|1|/psl16 |tPostScript Disk Access Notes |/su disktool.psl|1|/psl17 |tPostScript Disk Tools |/su psinscrt.psl|1|/psl18 |tPostScript Insider Secrets |/su pssearch.psl|1|/psl19 |tPostScript Search & Replace |1|/shiftout |/aqua |/black |t|t more\274 ) cl startnewpage (|6|/shiftin |/staytint1 |/burplebox8 |/su refsum1.html|1|/psl20 |tReferral Log Analyzer |/su reflog1.html|1|/psl21 |tReferral Log Reader |/su reflog1.psl|1|/psl22 |tReferral Log Report Generator |/su refsum1.psl|1|/psl23 |tReferral Log Summary Analyzer |/su searepl.psl|1|/psl24 |tSearch & Replace Demo |/su weberru2.psl|1|/psl25 |tWeb Error File Utilities |/su grabsrch.psl|1|/psl26 |tWeb Query Log Extractor |/su grabrefs.psl|1|/psl27 |tWeb Referral Log Extractor |1|/shiftout |/aqua |/black |h |c For Further Help |d Consulting assistance on any and all of these topics can be found at |/surl |6http://www.tinaja.com/info01.asp|1|/info01 . |h Additional |/surl |6GuruGrams|1|/gurgrm01 await your ongoing support as a |/surl |6Synergetics Partner|1|/advt01 . ) cl startnewpage %%%%%%%%%%%%%%%%%%%% % EOF