Copyright 1995-2016 by Kevin G. Barkes All rights reserved. This article may be duplicated or redistributed provided no alterations of any kind are made to this file. This edition of DCL Dialogue is sponsored by Networking Dynamics, developers and marketers of productivity software for OpenVMS systems. Contact our website www.networkingdynamics.com to download free demos of our software and see how you will save time, money and raise productivity! Be sure to mention DCL Dialogue! DCL DIALOGUE Terminal Irritations Originally published January, 1995 By Kevin G. Barkes There are several things I really detest. The "skin" on hot chocolate. GPFs in Windows. Yahoos who post their political ramblings in inappropriate Usenet newsgroups. Those new stupid compressed end credits on NBC television shows. But what really irks me the most are people who embed control codes in DCL command procedures. When you attempt to print these files, the output device has a nervous breakdown. It either starts shooting paper all over the place or, if a laser printer, throws it into an autistic self-diagnosis state that even a power-off restart can't clear. There are two reasons for this situation: the command file writer is picking up terminal escape codes from existing command files and/or is too lazy to learn the proper escape code sequences for DCL. I wrote USETERM.COM about seven years ago to deal with this problem. The procedure defines global symbols which are used to change display characteristics and terminal attributes. If invoked without parameters, the global symbols are defined and can then be called from other procedures. If you're a real slouch (like me) and don't want to bother to memorize those global symbols, you can supply a GOTO label and other parameters to USETERM directly and have it do the terminal manipulation for you. If you wanted to set up a scrolling region on the terminal beginning on line 15 and extending two lines, you would issue the following commands: $ @USETERM SCROLL 15 17 $ WRITE SYS$OUTPUT SCROLL Take a look at DEMO.COM (Program 2) for examples. And stop sticking escape codes in procedures you send me. AUTHOR! AUTHOR! It turns out that Jack Harvey of Securities Industry Automation Corporation in Brooklyn, NY is the author of the "shaggy VAX story" which appeared in the November column. "The first publication of "The Immortal Murderer" was on DECUServe, the DECUS bbs, where it still can be seen," Jack reports. "It was picked up there and published by a Canadian LUG. Since it is public domain, I expect it has gone many places in the five years since I wrote it." Readers desiring their own shot at immortality can forward their shaggy VAX stories ASAP. I'd like to feature one in our April issue... so start scribbling now. ****************** Launching '95- From t-shirts and Internet taglines, here are some quotes to consider as we begin the New Year: "I'm out of the loop, and that's the way I like it."- T-shirt. "When in doubt, manipulate the data."-T-shirt. "Quality is Job 1.1!"-Microsoft "Technology is dominated by two types of people: those who understand what they do not manage, and those who manage what they do not understand."-Putt's Law And from computer pioneer Seymour Cray, discussing the characteristics of virtual memory operating systems: "Memory is like an orgasm. It's a lot better if you don't have to fake it." ****************** Kevin G. Barkes is an independent consultant who knows the complete lyrics to the theme song of the PBS series "Where In The World is Carmen Sandiego"; feels that the inverse even/odd correlation of "goodness" between releases of OpenVMS and Star Trek movies is still in effect; is puzzled by Digital's policy of sending license paks at great expense via UPS in absurdly heavy composite cardboard/neutronium envelopes strong enough to endure a warp core breach; and admits to reading Unix Review, but only for Stan Kelly-Bootle's column. Kevin lurks on the comp.os.vms newsgroup and can be reached at kgbarkes@gmail.com. -------------------------------------------------------------- PROGRAM 1. $! USETERM.COM $! Sets up symbols which can be used to change terminal $! display characteristics and attributes. $! Define symbols so escape sequences in this command file $! are all "printable." $ ESC[0,7] = %X1B ! Escape character $ CSI = ESC+"[" ! Control sequence introducer $ BELL[0,7] = %X7 ! Bell $! $! Trap errors: $ ON WARNING THEN GOTO CATCH_ERROR $! $! If specified, execute one of the sequences $! requiring passed variables: $! $ IF P1 .NES. "" THEN GOTO 'P1' $! $! Turn on/off bold or increased intensity: $ BOLD_ON == CSI+"1"+"m" $ BOLD_OFF == CSI+"2"+"2"+"m" $! Turn on/off underlining: $ ULINE_ON == CSI+"4"+"m" $ ULINE_OFF == CSI+"2"+"4"+"m" $! Turn on/off blinking: $ BLINK_ON == CSI+"5"+"m" $ BLINK_OFF == CSI+"2"+"5"+"m" $! Turn on/off reverse image: $ REV_ON == CSI+"7"+"m" $ REV_OFF == CSI+"2"+"7"+"m" $! Turn off all attributes: $ NORMAL == CSI+"0"+"m" $! Turn on single-width: $ S_WIDTH == ESC+"#"+"5" $! Turn on double-width: $ D_WIDTH == ESC+"#"+"6" $! Double-height sequences: $ D_HEIGHT_TOP == ESC+"#"+"3" $ D_HEIGHT_BOT == ESC+"#"+"4" $! Save current cursor position: $ S_CURSOR == ESC+"7" $! Restore previously-saved position: $ R_CURSOR == ESC+"8" $! Move cursor down one line in same column: $ IND == ESC+"D" $! Move cursor up one line in same column: $ R_IND == ESC+"M" $! Move cursor to first position on next line: $ N_LINE == ESC+"E" $! Erase the entire display, change to single-width, $! cursor does not move: $ C_ALL == CSI+"2"+"J" $! Erase the display from the start of screen $! to the current position: $ C_TO_START == CSI+"1"+"J" $! Erase the display from the current position $! to the end of the screen: $ C_TO_END == CSI+"0"+"J" $! Return the cursor to line 1, column 1: $ HOME_SCREEN == CSI+"0"+"0"+"H" $! Reposition the cursor to line 1, $! column 1 and clear the screen: $ CLEAR_SCREEN == HOME_SCREEN+C_TO_END $! Terminal test: $ TERMTEST == ESC+"#"+"8" $! Terminal modes: $! Change to 132-column mode: $ C132 == CSI+"?"+"3"+"h" $! Change to 80-column mode: $ C80 == CSI+"?"+"3"+"l" ! (lower case L) $! Set smooth scrolling: $ SMOOTH == CSI+"?"+"4"+"h" $! Set jump scrolling: $ JUMP == CSI+"?"+"4"+"l" ! (lower case L) $! Set screen to reverse video: $ R_VIDEO == CSI+"?"+"5"+"h" $! Set screen to normal video: $ N_VIDEO == CSI+"?"+"5"+"l" ! (lower case L) $! Turn auto-wrap on: $ WRAP_ON == CSI+"?"+"7"+"h" $! Turn auto-wrap off: $ WRAP_OFF == CSI+"?"+"7"+"l" ! (lower case L) $! Turn auto-repeat on: $ REPEAT_ON == CSI+"?"+"8"+"h" $! Turn auto-repeat off: $ REPEAT_OFF == CSI+"?"+"8"+"l" ! (lower case L) $ EXIT $! Set scrolling area according to passed 'p' parameters: $ SCROLL: $ SCROLL == CSI+P2+";"+P3+"r" $ EXIT $! Move cursor up: $ UP: $ UP == CSI+P2+"A" $ EXIT $! Move cursor down: $ DOWN: $ DOWN == CSI+P2+"B" $ EXIT $! Move cursor forward: $ FORWARD: $ FORWARD == CSI+P2+"C" $ EXIT $! Move cursor backward: $ BACKWARD: $ BACKWARD == CSI+P2+"D" $ EXIT $! Position cursor: $ POSITION: $ POSITION == CSI+P2+";"+P3+"f" $ EXIT $! Error handling: $ CATCH_ERROR: $! (Status code %X38148 is an unsatisfied goto) $ IF $STATUS .EQ. %X38148 THEN GOTO BADPARM $ WRITE SYS$OUTPUT "Unknown error." $ EXIT $ BADPARM: $ WRITE SYS$OUTPUT P1," is an invalid parameter." $ EXIT ********************************** PROGRAM 2. $! DEMO.COM $! Command procedure to demonstrate the use of $! some of the symbol assignments in USETERM.COM $ WSO := WRITE SYS$OUTPUT $ PAUSE1 := WAIT 00:00:01 $ PAUSE2 := WAIT 00:00:02 $ PAUSE3 := WAIT 00:00:03 $ PAUSE4 := WAIT 00:00:04 $ USETERM := @USETERM $ USETERM $ WSO CLEAR_SCREEN $ USETERM POSITION 12 15 $ USETERM FORWARD 14 $ WSO POSITION+D_HEIGHT_TOP+"DEMO.COM" $ WSO FORWARD+D_HEIGHT_BOT+"DEMO.COM" $ WSO R_VIDEO $ PAUSE1 $ WSO N_VIDEO $ PAUSE1 $ WSO R_VIDEO $ PAUSE1 $ WSO N_VIDEO $ PAUSE1 $ WSO CLEAR_SCREEN $ COPY/NOLOG SYS$INPUT SYS$OUTPUT By using the symbols defined in USETERM.COM, you can display a number of terminal characteristics, including: $ PAUSE1 $ WSO BOLD_ON,"Bold type",BOLD_OFF $ PAUSE1 $ WSO " ",ULINE_ON,"Underlined type",ULINE_OFF $ PAUSE1 $ WSO " ",BLINK_ON,"Blinking type,",BLINK_OFF $ WSO "" $ PAUSE1 $ WSO " ",REV_ON,- "Reversed type",REV_OFF $ WSO BOLD_ON,"And ",ULINE_ON,"combinations ",BLINK_ON,"of ",REV_ON,"each." $ WSO NORMAL,"" $ PAUSE3 $ WSO D_WIDTH,"Display double width lines," $ PAUSE2 $ WSO D_HEIGHT_TOP,"or double height lines" $ WSO D_HEIGHT_BOT,"or double height lines" $ USETERM SCROLL 20 24 $ WSO SCROLL $ WSO "" $ COPY/NOLOG SYS$INPUT SYS$OUTPUT You can set up a scrolling window for your command procedures, leaving your original display intact. $ PAUSE2 $ COPY/NOLOG SYS$INPUT SYS$OUTPUT You can change your terminal characteristics.... $ PAUSE1 $ WSO JUMP $ COPY/NOLOG SYS$INPUT SYS$OUTPUT From Jump Scrolling.... $ PAUSE2 $ WSO SMOOTH $ COPY/NOLOG SYS$INPUT SYS$OUTPUT To Smooth Scrolling... $ WSO JUMP $ PAUSE2 $ WSO CLEAR_SCREEN $ USETERM UP 5 $ USETERM DOWN 15 $ USETERM FORWARD 20 $ WSO DOWN,BOLD_ON,BLINK_ON,"Move" $ PAUSE2 $ WSO UP,FORWARD,"around",FORWARD,UP,"the",UP,FORWARD,"screen",NORMAL $ PAUSE2 $ WSO DOWN,"Change the terminal to 132 character display..." $ PAUSE2 $ WSO C132 $ WSO "and back to 80 columns..." $ PAUSE2 $ WSO C80 $ PAUSE2 $ WSO "Save a cursor position: X",S_CURSOR $ PAUSE2 $ USETERM DOWN 15 $ WSO DOWN,"Move",R_IND,"around",R_IND,"the",R_IND,"screen...",IND,"Then",- R_CURSOR,"return to the marked position...." $ PAUSE2 $ WSO "Erase to the beginning to the screen..." $ PAUSE2 $ WSO C_TO_START $ WSO "And to the end..." $ PAUSE2 $ WSO C_TO_END $ PAUSE2 $ WSO "Clear the screen & maintain the current cursor position." $ PAUSE2 $ WSO C_ALL,"All from DCL!" $ PAUSE2 $ WSO "END OF DEMO.COM" $ PAUSE2 $ WSO CLEAR_SCREEN $ EXIT