Article 2936 of vmsnet.misc: Path: cs.utk.edu!gatech!newsxfer.itd.umich.edu!nntp.cs.ubc.ca!unixg.ubc.ca!world!gwwong From: gwwong@world.macblo.ca Newsgroups: comp.os.vms,vmsnet.misc Subject: Re: VT-xxx esc code - Corrected APRINT.COM Message-ID: <1994May13.092716.37@world> Date: 13 May 94 09:27:16 PST References: <1994May10.152032.35@world> Organization: MacMillan Bloedel Research Lines: 219 Xref: cs.utk.edu comp.os.vms:88503 vmsnet.misc:2936 > Date: 11 May 94 09:40:00 CST > From: "Thomas A Sachey" > Subject: RE: VT-xxx escape codes - turn printer on > To: "WONG" > > Gary: > > Was most appreciative of your post concerning escape codes for port printing > from a video terminal. Been looking for a good one for a long time. I've tried > your program and all works well until I get to 'check_type:'(see below). > > After .and. f$file_attributes("''filespec'","^*^ - there seems to be something > missing since I get DCL error when trying to execute this phase. After error, > program goes to "Press key when paper is aligned:". When return > is entered printing is fine. > > Can you forward the remaining code to this line.... > My apologies to all on the 'net for posting _unfinished code_ ... forgive me, it was late one night in 1988 when I *last* looked at this DCL hack of mine. Anyway, here it is *corrected* (read: I tested it _briefly_ today!) for other VMSers. Please note that it was originally written in 1984 so it refers to dated DEC LA50, LA100, LA120 printers, but just as useful today -- I hacked it to work at home with my PC/486 running Reflections 4 VT emulator software to control my HP Laserjet II on the printer port. Enjoy! --- CUT HERE --- BEGINNING OF CODE --- $ v = f$verify(f$integer(f$trnlnm("APRINT_DEBUG"))) ! Turn off verify $!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! $! APRINT.COM - Print a file through a video terminal's attached printer port. ! $! Gary Wong, MacMillan Bloedel Research, Updated: 05-NOV-1988. ! $!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! $ set noon $ success = 0 ! Initialize "completed print" flag $ reset1 = "" ! Initialize pitch reset $ reset2 = "" ! Initialize print quality reset $ set_form = "" ! Initialize SET TERMINAL/FORM parameter $ set_tabs = "" ! Initialize SET TERMINAL/TABS parameter $ set_wrap = "" ! Initialize SET TERMINAL/WRAP parameter $ bell[0,7] = %D07 ! Define the character $ ff[0,7] = %D0 ! Initialize Form Feed to a Null $ esc[0,7] = %D27 ! Define Escape character $ csi = "''esc'[" ! Define Control Sequence Initiator $ port_on = "''csi'5i" ! Define VT102 Printer Port ON Sequence $ port_off = "''csi'4i" ! Define VT102 Printer Port OFF Sequence $ bold = "" ! Use default: no bolding $ density = "" ! Use default: normal density $ cpi = "" ! Use default: 10 characters/inch $! $! ADD FOLLOWING 2 DCL LINES FOR TERMINALS THAT ONLY USE VT52 MODE CONTROL $! $!cut port_on = "''csi'5i''esc'W" ! VT52 port ON/OFF sequences are added $!cut port_off = "''esc'X''csi'4i" ! inside the normal VT102 definition. $! $! GET FILENAME AND ANY OPTIONAL PRINT SWITCHES $! $get_filename: $ if f$length(p1) .ne. 0 then goto check $ inquire p1 "Filename to print" $ goto get_filename $check: $ if f$extract(0,1,p1) .eqs. "?" then goto help $ length = f$length(p1) $ if length .eq. 0 then goto end_it $ delim1 = f$locate(",",p1) $ if delim1 .eq. length then delim1 = f$locate(" ",p1) $ if delim1 .eq. length then goto skip_1 $ p2 = f$extract(delim1+1,length-delim1,p1) $ p1 = f$extract(0,delim1,p1) $skip_1: $ length = f$length(p2) $ if length .eq. 0 then goto skip_2 $ delim2 = f$locate(",",p2) $ if delim2 .eq. length then delim2 = f$locate(" ",p2) $ if delim2 .eq. length then goto skip_2 $ p3 = f$extract(delim2+1,length-delim2,p2) $ p2 = f$extract(0,delim2,p2) $skip_2: $ filespec = f$search(p1) $ if f$length(filespec) .ne. 0 then goto check_attributes $ write sys$output " " $ write sys$output "Sorry! No such file, please try again.",bell $ p1 = "" $ goto get_filename $! $! ON-LINE USER INSTRUCTIONS $! $help: $ write sys$output "''csi';H''csi'2J" ! Home and clear screen $ type sys$input ! Dump instructions This utility prints a file through the printer port attached to a video terminal. The APRINT symbol is called at the DCL command level as: $ APRINT filename.typ switch1 switch2 where 'switch1' and 'switch2' are combinations of the following optional parameters for DEC LA-series printers: NORMAL Normal printing (default: draft quality). BOLD Bold printing (darkened print). ENHANCED Enhanced print density (near letter quality). 5CPI 5 Characters/inch horizontal pitch. 6CPI 6 Characters/inch horizontal pitch. 8CPI 8.25 Characters/inch horizontal pitch. 10CPI 10 Characters/inch horizontal pitch (default). 12CPI 12 Characters/inch horizontal pitch. 16CPI 16.5 Characters/inch horizontal pitch. If 'switch1' and 'switch2' are not specified, then the default is NORMAL print and 10 CPI. Only the first 2 characters of each parameter are necessary for APRINT to understand what you want. Note that not all combinations will work. Refer to the specific printer manual for valid combinations. $ goto end_it $! $! CHECK FILE ATTRIBUTES I.E. DOES IT NEED CONVERSION? $! $check_attributes: $ f_eof = f$file_attributes("''filespec'","eof") $ if f_eof .gt. 0 then goto check_type $ write sys$output "Cannot print ''filespec' -> File is empty!''bell'" $ goto no_open $check_type: $ f_rfm = f$file_attributes("''filespec'","rfm") $ if f_rfm .eqs. "VAR" then goto check_f_org $ if f$extract(0,3,f_rfm) .eqs. "STM" then goto check_f_org $ write sys$output "Cannot print ''filespec' -> Record format is ''f_rfm'" $ goto no_open $check_f_org: $ f_org = f$file_attributes("''filespec'","org") $ if f_org .eqs. "SEQ" then goto print_it $ write sys$output - "Cannot print ''filespec' -> File organization is ''f_org'" $ goto no_open $! $! SET UP PRINT DENSITY, HORIZONTAL PITCH $! $print_it: $ on control_y then goto end_it $ if p8 .ne. 1 then inquire/nopunctuation tmp - "Press key when paper is aligned:" $ if p2 .eqs. "" then p2 = "NORMAL" ! Default print density $ if p3 .eqs. "" then p3 = "10CPI" ! Default horz. pitch $ p2 = f$extract(0,2,p2) ! Get first 2 characters $ p3 = f$extract(0,2,p3) ! Get first 2 characters $ if p2 .eqs. "B" .or. p3 .eqs. "B" .or. - p2 .eqs. "BO" .or. p3 .eqs. "BO" then - bold = "''csi'1m" ! Enable BOLD print $ if p2 .eqs. "E" .or. p3 .eqs. "E" .or. - p2 .eqs. "EN" .or. p3 .eqs. "EN" then - density = "''csi'2""z" ! Enable ENHANCED print $ if p2 .eqs. "5" .or. p3 .eqs. "5" .or. - p2 .eqs. "5C" .or. p3 .eqs. "5C" then - cpi = "''csi'5w" ! Set 5 CPI pitch $ if p2 .eqs. "6" .or. p3 .eqs. "6" .or. - p2 .eqs. "6C" .or. p3 .eqs. "6C" then - cpi = "''csi'6w" ! Set 6 CPI pitch $ if p2 .eqs. "8" .or. p3 .eqs. "8" .or. - p2 .eqs. "8C" .or. p3 .eqs. "8C" then - cpi = "''csi'8w" ! Set 8.25 CPI pitch $ if p2 .eqs. "12" .or. p3 .eqs. "12" then - cpi = "''csi'2w" ! Set 12 CPI pitch $ if p2 .eqs. "16" .or. p3 .eqs. "16" then - cpi = "''csi'4w" ! Set 16.25 CPI pitch $ $ ff[0,7] = %D12 ! Re-define Form Feed $ if cpi .nes. "" then - reset1 = "''csi'0w''csi'0z" ! Pitch size reset $ if bold .nes. "" .or. density .nes. "" then - reset2 = "''csi'0m''csi'0""z" ! Print density reset $! $! SAVE TERMINAL CHARACTERISTICS, THEN SET UP FOR PRINTING $! $ tt_form = f$getdvi("tt","tt_mechform") ! Save *critical* $ tt_tabs = f$getdvi("tt","tt_mechtab") ! terminal setting $ tt_wrap = f$getdvi("tt","tt_wrap") ! characteristics... $ if tt_form .eqs. "FALSE" then set_form = "/NOFORM" $ if tt_tabs .eqs. "TRUE" then set_tabs = "/TAB" $ if tt_wrap .eqs. "TRUE" then set_wrap = "/WRAP" $ set terminal/form/notab/nowrap/page=66/nobroadcast $! $! SEND FILE TO THE PRINTER PORT $! $ write sys$output port_on,cpi,bold,density ! Turn ON printer port $ type 'filespec' ! TYPE command does it $ success = 1 ! Flag "completed print" $end_it: $! $! RESET TERMINAL CHARACTERISTICS HERE IF NECESSARY AFTER CTRL/Y $! $ write sys$output ff,reset1,reset2,port_off ! Turn OFF printer port $ set terminal 'set_form' 'set_tabs' 'set_wrap' - /page=24/broadcast ! Reset characteristics $ if success .eq. 1 then - write sys$output "Print completed successfully!",bell $! $! CHECK IN ANY NEW MAIL MESSAGES BROADCAST WHILE WE WERE DISABLED $! $ user = f$getjpi("","username") $ fulluser[0,31] := 'user' $ open /share=write /read /error=no_open mailbox SYS$SYSTEM:VMSMAIL.DAT $ read /index=0 /error=no_read /key="''fulluser'" mailbox record $ mcount = f$cvui(33*8,16,record) $ if mcount .eq. 1 then write sys$output - "You have 1 new MAIL message." $ if mcount .gt. 1 then write sys$output - "You have ''mcount' new MAIL messages." $no_read: $ close mailbox $no_open: $ if v then set verify --- CUT HERE --- END OF CODE --- --------------------------------+---------------------------------------------- Gary Wong | Usual Disclaimer: Senior Systems Engineer | "Any views or opinions expressed here are not MacMillan Bloedel Research | those of my employer, organization, _nor_ Internet: wong@calvin.macblo.ca | my wife. I speak for myself (right, dear?)" --------------------------------+---------------------------------------------- Article 2938 of vmsnet.misc: Newsgroups: comp.os.vms,vmsnet.misc Path: cs.utk.edu!gatech!europa.eng.gtefsd.com!MathWorks.Com!news2.near.net!noc.near.net!mv!mv.mv.com!cantor From: cantor@mv.mv.com (David A. Cantor) Subject: Re: VT-xxx esc code - Corrected APRINT.COM Message-ID: Nntp-Posting-Host: mv.mv.com Sender: usenet@mv.mv.com (System Administrator) Organization: MV Communications, Inc. Date: Sun, 15 May 1994 04:33:34 GMT References: <1994May10.152032.35@world> <1994May13.092716.37@world> Lines: 53 Xref: cs.utk.edu comp.os.vms:88582 vmsnet.misc:2938 In article <1994May13.092716.37@world>, wrote: >[...] >Anyway, here it is *corrected* (read: I tested it _briefly_ today!) for other >VMSers. Please note that it was originally written in 1984 so it refers to >dated DEC LA50, LA100, LA120 printers, but just as useful today -- I hacked it >to work at home with my PC/486 running Reflections 4 VT emulator software to >control my HP Laserjet II on the printer port. Enjoy! > > [ Most of the code not reproduced here. DAC. ] >$! >$! ADD FOLLOWING 2 DCL LINES FOR TERMINALS THAT ONLY USE VT52 MODE CONTROL >$! >$!cut port_on = "''csi'5i''esc'W" ! VT52 port ON/OFF sequences are added >$!cut port_off = "''esc'X''csi'4i" ! inside the normal VT102 definition. >$! Because REAL VT52 terminals will go into screen hold mode upon receiving a ESC [ sequence (which a CSI is), it is necessary either to send a VT52 release screen sequence ESC \ along with and immediately after the VT1xx codes, or (IMAO) better yet, just replace with VT1xx codes with the VT52 codes. Once a VT52 receives the sequence ESC [, it then MUST receive the sequence ESC \ before it receives a LF to avoid locking up the screen! That is, the above definitions need to be changed to this: $!cut port_on = "''csi'5i''esc'\''esc'W" $!cut port_off = "''esc'X''csi'4i''esc'\" I would define the stuff this way: $ ESC = "" ! Make sure it's a _character_ string $ ESC[0,8] = %X1B ! That's 8 bits starting at bit 0 $ CSI = ESC + "[" ! No ugly, hard-to-read embedded double apostrophes $ ! within quotes $ port_on = CSI + "5i" $ port_off = CSI + "4i" $ $! For use on a VT52, use these instead: $! port_on = ESC + "W" $! port_off = ESC + "X" Dave C. 11.5 year veteran of DEC and DCL and ex-president of the society for keeping around old terminals and avoiding the unnecesary use of double apostrophes :-) -- -- David A. Cantor +1 203-444-7268 (203-444-RANT) 453 Bayonet St., #16 Internet: cantor@mv.mv.com New London, CT 06320 Foxwoods blackjack and craps dealer I work at and for Foxwoods, but do not speak for Foxwoods.