Copyright 1987-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 Originally published March, 1987 By Kevin G. Barkes DCL TERMINAL MANIPULATION Last month in response to a reader's request, I made an appeal to terminal wizards for information on changing terminal characteristics from within DCL command procedures. Because of the lead time involved in magazine production, it will probably be a few more months until that reader-written comprehensive article arrives. In the meantime, the question piqued my curiosity. So, armed with the VT220 Pocket Programmer Guide and the August, 1985 issue of The VAX Professional, I decided to whip together a fast command procedure to give readers some terminal handling capability until the definitive work arrives in the mail from parts unknown. The VAX PRO article, "Nifty Things To Do With VAX DCL Command Procedures", by Allen Watson, included a method of including terminal escape sequences in command files without really including them, "a distinction," author Watson notes, "which is extremely important when it comes time to... (print out to a line printer) the command procedure." The first command procedure, USETERM.COM, defines the global symbols which are used to change display characteristics and terminal attributes. The command file DEMO.COM runs a little demonstration on your terminal and shows the various methods of utilizing the definitions. If USETERM is invoked without parameters (e.g., $@USETERM), the "static" definitions are assigned as global symbols. If a valid "GOTO" label is supplied, the procedure jumps directly to the named label, assigns the values passed to a global symbol of the same name, then immediately exits. For example, to set up a scrolling region on the terminal starting on line 10 and extending for five lines, you would do the following: $ @USETERM SCROLL 10 15 $ WRITE SYS$OUTPUT SCROLL The procedures should work on VT220s set up to recognize 7-bit control sequences as well as VT10xs with advanced video options. Armed with these samples, users should be able to devise a number of permutations of the sequences. If you do take the plunge, be certain to share them with us. ***** PROCEDURE 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,32] = %X1B ! Escape character $ CSI = ESC+"[" ! Control sequence introducer $ BELL[0,32] = %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" $! $! Erases the entire display, changed to single-width, cursor does not move: $ C_ALL == CSI+"2"+"J" $! $! Erases the display from the start of screen to the current position: $ C_TO_START == CSI+"1"+"J" $! $! Erases 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 $! ***** PROCEDURE 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 ********************* Kevin G. Barkes is an independent consultant. He publishes the KGB Report newsletter, operates the www.kgbreport.com website, lurks on comp.os.vms, and can be reached at kgbarkes@gmail.com.