[Search for users] [Overall Top Noters] [List of all Conferences] [Download this site]

Conference turris::pascal

Title:DEC Pascal Notes
Notice:See note 1 for kits. Bug reports to CLT::DEC_PASCAL_BUGS
Moderator:TLE::REAGAN
Created:Sat Jan 25 1986
Last Modified:Tue Jun 03 1997
Last Successful Update:Fri Jun 06 1997
Number of topics:2675
Total number of notes:13409

2673.0. "How to flush terminal output without using writeln?" by SNOC01::63620::GRAHAM (Russell GRAHAM) Tue May 13 1997 07:17

Hi,

I have a customer who is migrating from OVMS VAX (V6.0) to OVMS AXP (V7.1).
They have an application written largely in Pascal with some macro-32.

They have a mechanism to control the user interface screens on VT terminals,
where the pascal code does a lot of write(); statements
to format information on the screen, paint menu options, etc.
Then they call a macro routine that does a QIOW read with prompt call.
They "dig" into some internal data structures to get the buffer start address
and buffer next-to-add pointer that pascal maintains (where all the text in
previous write statements is stored) and provide this to the QIOW to form the
prompt.
In effect they need never use a writeln to flush the output to the screen.

This is old code and has always worked on the VAX through various versions
of OVMS and the Pascal compiler.
But now, it won't work on the alpha... surprise!

There is a lot of code that uses this mechanism, so they don't want to recode
it all.

What is required, is either:
- the equivant of the "magic numbers" used on the VAX ,
  by the routine mu_prmptrd.
  Refer to the attached list file of the macro code.
  Refer to lines 01c0, 01c4.
- some way to flush the text held in the buffer without doing a writeln.
  (The writeln adds a cr,lf which would mess up the screen)
- an alternate mechanism ...

Any help or comments would be appreciated.

Russell Graham
NSIS, Sydney
@SNO
----------------------------------------------------------------------

MU_TRMIO                                                                
12-MAY-1997 16:43:05  VAX MACRO V5.4-3            Page   1
                                                                        
27-AUG-1993 17:16:41  [SOURCE.MENU]TERMIO.MAR;22        (1)

                                     0000     1 	.TITLE	MU_TRMIO
                                     0000     2 ;
                                     0000     3 ;	Modifications:
                                     0000     4 ;
                                     0000     5 ;	  
                                     0000     6 ;	  MEC	
27-JUL-93	Add handling of F6-F20 keys in MU_PRMPT.
                                     0000     7 ;PMP1323  MEC	
27-AUG-93	Commented out go_f7 to go_f20.
                                     0000     8 ;
                                     0000     9 ;++
                                     0000    10 ;	This module contains
subroutines used for getting input from a CRT.
                                     0000    11 ;
                                     0000    12 ;	1)	MU_TINIT
- assign channel to SYS$INPUT, and set up.
                                     0000    13 ;			A
channel is assigned to SYS$INPUT.
                                     0000    14 ;			GETDVI
is used to get the device class.
                                     0000    15 ;			If the
device class is "terminal", then
                                     0000    16 ;			
a sensemode QIO is used to get the chars.
                                     0000    17 ;			
If the terminal is a VT100 then
                                     0000    18 ;				
the terminal is set as /ESCAPE,
                                     0000    19 ;				
and the type flag is set accordingly.
                                     0000    20 ;
                                     0000    21 ;		The input to
MU_TINIT is the length of reads to do for
                                     0000    22 ;		future calls to
MU_PRMPTRD, and an array showing the
                                     0000    23 ;		code returns
wanted for the different type of terminators.
                                     0000    24 ;		these codes are
assumed to be in the order of the
                                     0000    25 ;		go codes as
enumerated below ( empty, text, up, ... )
                                     0000    26 ;
                                     0000    27 ;	2)	MU_PRMPTRD
- get data from the terminal.
                                     0000    28 ;			
- reads data into the users buffer.
                                     0000    29 ;			
- returns the length read, and an indication
                                     0000    30 ;				
 of any special return.
                                     0000    31 ;			
- optionally timesout
                                     0000    32 ;			
- optionally clears type ahead buffer
                                     0000    33 ;			
- optionally does not echo the input
                                     0000    34 ;	function MU_PRMPTRD ( 
var pfv  	: text;
                                     0000    35 ;			
var buffer 	: varying [n] of char;
                                     0000    36 ;			
timeout  	: integer := 0 ;
                                     0000    37 ;			
clear_type	: boolean := false;
                                     0000    38 ;			
no_echo		: boolean := false)
                                     0000    39 ;			       
: mu_response ;
                                     0000    40 ;
                                     0000    41 ;	3)	MU_EXHAN
- exit handler to set terminal back to
                                     0000    42 ;				
 no escape.
                                     0000    43 ;
                                     0000    44 ;	4)	MU_MUMAKE
- change lx_buffer ( packed ) to mu_text
                                     0000    45 ;		mu_mumake (
lx_buffer, lx_length, var mu_text )
                                     0000    46 ;	5)	MU_LXMAKE
- change mu_text ( varying) to lx_buffer
                                     0000    47 ;		mu_lxmake (
mu_text, var lx_buffer, var lx_length )
                                     0000    48 ;--

MU_TRMIO                                                                
12-MAY-1997 16:43:05  VAX MACRO V5.4-3            Page   2
                                                                        
27-AUG-1993 17:16:41  [SOURCE.MENU]TERMIO.MAR;22        (2)

                                     0000    50   	$DCDEF
                                     0000    51   	$DVIDEF
                                     0000    52   	USEFUL_MACROS
                                     0000    53 ;
                                     0000    54 ;		Data area
                           00000009  0000    55 asc_tab = 9
                           0000000A  0000    56 asc_lf = 10
                           0000000B  0000    57 asc_vt = 11
                           0000000C  0000    58 asc_ff = 12
                           0000000D  0000    59 asc_cr = 13
                           0000001A  0000    60 asc_eof = 26
                           0000001B  0000    61 asc_esc = 27
                                     0000    62 ;
                           00000000  0000    63 go_empty = 0
                           00000001  0000    64 go_nowhere = 1
                           00000002  0000    65 go_north = 2
                           00000003  0000    66 go_south = 3
                           00000004  0000    67 go_east = 4
                           00000005  0000    68 go_west = 5
                           00000006  0000    69 go_away = 6
                           00000007  0000    70 go_pf1 = 7
                           00000008  0000    71 go_pf2 = 8
                           00000009  0000    72 go_pf3 = 9
                           0000000A  0000    73 go_pf4 = 10
                           0000000B  0000    74 go_timed = 11
                           0000000C  0000    75 go_f6 = 12
                           0000000D  0000    76 go_f7 = 13
                           0000000E  0000    77 go_f8 = 14
                           0000000F  0000    78 go_f9 = 15
                           00000010  0000    79 go_f10 = 16
                           00000011  0000    80 go_f11 = 17
                           00000012  0000    81 go_f12 = 18
                           00000013  0000    82 go_f13 = 19
                           00000014  0000    83 go_f14 = 20
                           00000015  0000    84 go_f15 = 21
                           00000016  0000    85 go_f16 = 22
                           00000017  0000    86 go_f17 = 23
                           00000018  0000    87 go_f18 = 24
                           00000019  0000    88 go_f19 = 25
                           0000001A  0000    89 go_f20 = 26
                                     0000    90 ;
                           0000000C  0000    91 go_max = go_f6			
; apply only keys in use 
                           0000000D  0000    92 go_length = go_max + 1
                                     0000    93 ;
                                     0000    94 ;		Read write data
                                     0000    95 ;
                                 00000000    96 	.PSECT
$LOCAL,PIC,USR,CON,REL,LCL,NOSHR,NOEXE,RD,WRT,LONG
                                     0000    97 ;
                                     0000    98 DESBLK:				
; exit handler control block
                           00000000  0000    99 	.LONG	0		
; link
                           00000000  0004   100 	.LONG	0		
; will be .ADDRESS	MU_EXHAN
                           00000001  0008   101 	.LONG	1		
; number of args ( the status address)
                           00000000  000C   102 	.LONG	0		
; will be .ADDRESS	EST
                           00000001  0010   103 EST:	.LONG	1		
; exit status
                  00000000 00000000  0014   104 TERMCHR:.LONG	0,0		
; init term characteristics
                               0000  001C   105 CHAN:	.WORD	0		
; channel to SYS$INPUT
                               0000  001E   106 TYPE:	.WORD	0		
; 0 = not known terminal

MU_TRMIO                                                                
12-MAY-1997 16:43:05  VAX MACRO V5.4-3            Page   3
                                                                        
27-AUG-1993 17:16:41  [SOURCE.MENU]TERMIO.MAR;22        (2)

                                     0020   107 ;				
; 1 = VT100 /VT52
                               0000  0020   108 TYPE2:	.WORD	0		
; 1 = VT100
                           0000002F  0022   109 RETURNS: .BLKB	go_length	
; returns for all the go codes.
                                     002F   110 ;
                                     002F   111 ;		Read only data
                                     002F   112 ;
                                 00000000   113 	.PSECT
$CODE,PIC,USR,CON,REL,LCL,SHR,EXE,RD,NOWRT,LONG
                                     0000   114 ;
                  FFFFFFFF 00000000  0000   115 TERMBUF:	.LONG	0,-1	
; terminate on all control chars
                                     0008   116 				
; including TAB,LF,VT,FF,BS
                                     0008   117 ONETERMS:
                              00 0A  0008   118 	.BYTE	asc_lf, go_empty
; return go_empty if its an LF
                              04 09  000A   119 	.BYTE	asc_tab, go_east
; return go_east if its a TAB
                              06 1A  000C   120 	.BYTE	asc_eof, go_away
                              01 00  000E   121 	.BYTE	0, go_nowhere
                                     0010   122 TWOTERMS:
                              02 41  0010   123 	.BYTE	^A"A", go_north
                              03 42  0012   124 	.BYTE	^A"B", go_south
                              04 43  0014   125 	.BYTE	^A"C", go_east
                              05 44  0016   126 	.BYTE	^A"D", go_west
                              07 50  0018   127 	.BYTE	^A"P", go_pf1
                              08 51  001A   128 	.BYTE	^A"Q", go_pf2
                              09 52  001C   129 	.BYTE	^A"R", go_pf3
                              0A 53  001E   130 	.BYTE	^A"S", go_pf4
                              01 00  0020   131 	.BYTE	0, go_nowhere
                                     0022   132 
                                     0022   133   				
	; { MAL272 vvvvvvvvvv }
                                     0022   134 ; We call them 'fourterms', even
though there are 5 characters input from the
                                     0022   135 ; terminal. We just don't
reference the ESC character in this table, as the code
                                     0022   136 ; skips over it for us.
                                     0022   137 FOURTERMS:
                        0C 7E 37 31  0022   138   	.BYTE	^A"1", ^A"7",
^A"~", go_f6
                                     0026   139 ;  	.BYTE	^A"1", ^A"8",
^A"~", go_f7	{Not yet required PMP1323vv}
                                     0026   140 ;  	.BYTE	^A"1", ^A"9",
^A"~", go_f8
                                     0026   141 ;  	.BYTE	^A"2", ^A"0",
^A"~", go_f9
                                     0026   142 ;  	.BYTE	^A"2", ^A"1",
^A"~", go_f10
                                     0026   143 ;  	.BYTE	^A"2", ^A"3",
^A"~", go_f11
                                     0026   144 ;  	.BYTE	^A"2", ^A"4",
^A"~", go_f12
                                     0026   145 ;  	.BYTE	^A"2", ^A"5",
^A"~", go_f13
                                     0026   146 ;  	.BYTE	^A"2", ^A"6",
^A"~", go_f14
                                     0026   147 ;  	.BYTE	^A"2", ^A"8",
^A"~", go_f15
                                     0026   148 ;  	.BYTE	^A"2", ^A"9",
^A"~", go_f16
                                     0026   149 ;  	.BYTE	^A"3", ^A"1",
^A"~", go_f17
                                     0026   150 ;  	.BYTE	^A"3", ^A"2",
^A"~", go_f18
                                     0026   151 ;  	.BYTE	^A"3", ^A"3",
^A"~", go_f19
                                     0026   152 ;  	.BYTE	^A"3", ^A"4",
^A"~", go_f20       { PMP1323 ^^^^^^^^^  }
                              01 00  0026   153 	.BYTE	0, go_nowhere	
	; { MAL272 ^^^^^^^^^^^ }
                                     0028   154 ;
                                     0028   155 ;
         54 55 50 4E 49 24 53 59 53  0028   156 DEVNAM:	.ASCII	/SYS$INPUT/	
; The davice name.
                           00000009  0031   157 DEVNAM_L = .-DEVNAM

MU_TRMIO                                                                
12-MAY-1997 16:43:05  VAX MACRO V5.4-3            Page   4
                                                                        
27-AUG-1993 17:16:41  [SOURCE.MENU]TERMIO.MAR;22        (3)

                                     0031   159 ;++
                                     0031   160 ;	MU_TINIT	- assign
a channel to SYS$INPUT
                                     0031   161 ;			  get
the device characteristics
                                     0031   162 ;			  set
terminal as /ESCAPE
                                     0031   163 ;			  set up
an exit handler to set characteristics
                                     0031   164 ;			  as
/NOESCAPE.
                                     0031   165 ;			If the
terminal is not a VT100/VT52, release channel.
                                     0031   166 ;--
                               003C  0031   167 .ENTRY	MU_TINIT,^M<R2,R3,R4,R5>
; Assign channel, set characteristics
                   0000001E'GF   B4  0033   168 	CLRW	g^TYPE		
; assume unknown terminal.
      00000022'GF   04 BC   0D   28  0039   169 	MOVC3	#go_length,
@4(AP), -	; set up the return codes
                                     0042   170 		g^RETURNS
                         E3 AF   9F  0042   171 	PUSHAB	DEVNAM		
; make a descriptor for the name.
                            09   DD  0045   172 	PUSHL	#DEVNAM_L	
;  ( SYS$INPUT )
                       50   5E   D0  0047   173 	MOVL	SP, R0
                                     004A   174 	$ASSIGN_S
CHAN=CHAN,-	; Get a channel to SYS$INPUT.
                                     004A   175 		DEVNAM = (R0)
                         01 50   E8  005D   176 	BLBS	R0,10$		
; if LBC fail
                                 04  0060   177 	RET
                                     0061   178 ;
                       52   5E   D0  0061   179 10$:	MOVL	SP, R2		
; Where to get the device class.
              5E   000000C8 8F   C2  0064   180 	SUBL	#200, SP	
; room for itmlst
                       51   5E   D0  006B   181 	MOVL	SP, R1
                       81   04   B0  006E   182 	MOVW	#4, (R1)+	
; fill in item list
                       81   04   B0  0071   183 	MOVW	#DVI$_DEVCLASS,
(R1)+	; want the device class.
                       81   62   DE  0074   184 	MOVAL	(R2), (R1)+	
; place for buffer
                    81   04 A2   DE  0077   185 	MOVAL	4(R2), (R1)+	
; place for buffer length
                            81   D4  007B   186 	CLRL	(R1)+		
; terminator.
                       51   5E   D0  007D   187 	MOVL	SP, R1
                                     0080   188 	$GETDVI_S
CHAN=CHAN,-
                                     0080   189 			EFN =
#1,-
                                     0080   190 			ITMLST =
(R1)
                         39 50   E9  009A   191 	BLBC	R0, 200$
                                     009D   192 	$WAITFR_S	EFN= #1
              00000042 8F   62   D1  00A6   193 	CMPL	(R2), #DC$_TERM	
; is it a terminal ?
                            03   13  00AD   194 	BEQL	150$		
; if EQL no
                          00B1   31  00AF   195 	BRW	1000$		
; else no.
                       50   5E   D0  00B2   196 150$:	MOVL	SP, R0		
; use stack as IOSB
                                     00B5   197 	$QIOW_S	-		
; Now sense the characteristics.
                                     00B5   198 		EFN = #1,-
                                     00B5   199 		FUNC =
#IO$_SENSEMODE,-
                                     00B5   200 		CHAN = CHAN,-
                                     00B5   201 		IOSB = (R0),-
                                     00B5   202 		P1 = (R2),-	
; set the chars
                                     00B5   203 		P2 = #8
                         5A 50   E9  00D6   204 200$:	BLBC	R0, 500$	
; if LBC fail
                       50   6E   3C  00D9   205 	MOVZWL	(SP), R0	
; Check on the IOSB
                         54 50   E9  00DC   206 	BLBC	R0, 500$
              00000020'EF   01   90  00DF   207 	MOVB	#1, TYPE2	
; set as VT100
                 60 8F   01 A2   91  00E6   208 	CMPB	1(R2),
#DT$_VT100	; is it a VT100 ?
                            0D   13  00EB   209 	BEQL	210$		
; if EQL yes
                   00000020'EF   94  00ED   210 	CLRB	TYPE2		
; set as VT52
                 40 8F   01 A2   91  00F3   211 	CMPB	1(R2), #DT$_VT52
; is it VT52
                            69   12  00F8   212 	BNEQ	1000$		
; if NEQ no.
              00000014'GF   62   7D  00FA   213 210$:	MOVQ	(R2), g^TERMCHR	
; set the initial characteristics
                   0000001E'GF   B6  0101   214 	INCW	g^TYPE
        53 04 A2   00000000'8F   E2  0107   215 	BBSS	#TT$V_ESCAPE, -	
; branch if already escape

MU_TRMIO                                                                
12-MAY-1997 16:43:05  VAX MACRO V5.4-3            Page   5
                                                                        
27-AUG-1993 17:16:41  [SOURCE.MENU]TERMIO.MAR;22        (3)

                                     0110   216 		4(R2), 1000$	
;
     00000004'EF   0000017E'EF   9E  0110   217 	MOVAB	MU_EXHAN, DESBLK
+ 4	; set up the DESBLK ( do so now to
     0000000C'EF   00000010'EF   DE  011B   218 	MOVAL	EST, DESBLK + 12
;  make code shareable )
                                     0126   219 	$DCLEXH_S	-	
; declare an exit handler to
                                     0126   220 		DESBLK =
g^DESBLK	; switch back the chars.
                         2D 50   E9  0133   221 500$:	BLBC	R0, 1000$
                       50   5E   D0  0136   222 	MOVL	SP, R0
                                     0139   223 	$QIOW_S	-		
; Now sense the characteristics.
                                     0139   224 		EFN = #1,-
                                     0139   225 		FUNC =
#IO$_SETMODE,-
                                     0139   226 		CHAN = CHAN,-
                                     0139   227 		IOSB = (R0),-
                                     0139   228 		P1 = (R2),-	
; set the chars
                                     0139   229 		P2 = #8
                         06 50   E9  015A   230 	BLBC	R0, 1000$	
; if LBC fail
                       50   6E   3C  015D   231 	MOVZWL	(SP), R0	
; Check on the IOSB
                         00 50   E9  0160   232 	BLBC	R0, 1000$
                13 0000001E'GF   E8  0163   233 1000$:	BLBS	g^TYPE, 2000$	
; if all o.k.
                            50   DD  016A   234 	PUSHL	R0
                                     016C   235 	$DASSGN_S	CHAN =
CHAN
                       50   8E   D0  017A   236 	MOVL	(SP)+, R0
                                 04  017D   237 2000$:	RET			
; And that is that.

MU_TRMIO                                                                
12-MAY-1997 16:43:05  VAX MACRO V5.4-3            Page   6
                                                                        
27-AUG-1993 17:16:41  [SOURCE.MENU]TERMIO.MAR;22        (4)

                                     017E   239 ;++
                                     017E   240 ;	MU_EXHAN is an exit
handler set up to set the terminal as NO ESCAPE
                                     017E   241 ;
                                     017E   242 ;	It is only set up to be
called if the terminal has been set as
                                     017E   243 ;	ESCAPE by MU_TINIT.
                                     017E   244 ;--
                               0000  017E   245 MU_EXHAN:	.WORD	^M<>
                       5E   08   C2  0180   246 	SUBL	#8, SP
                       50   5E   D0  0183   247 	MOVL	SP, R0		
; use stack as IOSB
                                     0186   248 	$QIOW_S	-		
; Now sense the characteristics.
                                     0186   249 		EFN = #1,-
                                     0186   250 		FUNC =
#IO$_SETMODE,-
                                     0186   251 		CHAN = CHAN,-
                                     0186   252 		IOSB = (R0),-
                                     0186   253 		P1 = g^TERMCHR,-
; set the chars
                                     0186   254 		P2 = #8
                       50   01   D0  01AB   255 1000$:	MOVL	#1,R0
                                 04  01AE   256 	RET

MU_TRMIO                                                                
12-MAY-1997 16:43:05  VAX MACRO V5.4-3            Page   7
                                                                        
27-AUG-1993 17:16:41  [SOURCE.MENU]TERMIO.MAR;22        (5)

                           00000004  01AF   258 PFVARG      = 4
                           00000008  01AF   259 BUARG       = PFVARG + 4
                           0000000C  01AF   260 TIMARG      = BUARG + 4
                           00000010  01AF   261 CLTARG      = TIMARG + 4
                           00000014  01AF   262 ECHOARG     = CLTARG + 4
                           0000000C  01AF   263 FCBOFF      = 12
                           FFFFFFE8  01AF   264 FCBRECBEG   = -24	
                           FFFFFFEC  01AF   265 FCBRECCUR   = -20
                                     01AF   266 ;
                               03FC  01AF   267 .ENTRY
MU_PRMPTRD,^M<R2,R3,R4,R5,R6,R7,R8,R9>; read data.
                    50   08 BC   DE  01B1   268 	MOVAL	@BUARG(AP), R0	
; point to the varying n of char
                                     01B5   269 				
; R0 points to a descriptor.
                       59   60   3C  01B5   270 	MOVZWL	(R0), R9	
; get ret length for data
                    58   04 A0   D0  01B8   271 	MOVL	4(R0), R8	
; and R8 the varying string
                    51   04 BC   DE  01BC   272 	MOVAL	@PFVARG(AP), R1	
; point to the pascal file variable
                    51   0C B1   DE  01C0   273 	MOVAL	@FCBOFF(R1), R1	
; point to the FCB
                    57   E8 B1   DE  01C4   274 	MOVAL	@FCBRECBEG(R1),
R7	; R7 points to prompt buffer	
                         E8 A1   A3  01C8   275 	SUBW3	FCBRECBEG(R1),-
                         EC A1       01CB   276 		FCBRECCUR(R1),-
                            56       01CD   277 		R6		
; Length of output/prompt buffer
                         E8 A1   D0  01CE   278 	MOVL	FCBRECBEG(R1),-
                         EC A1       01D1   279 		FCBRECCUR(R1)	
; Reset the buffer
                            68   B4  01D3   280 	CLRW	(R8)		
; string starts as a zero.
                39 0000001E'GF   E8  01D5   281 	BLBS	g^TYPE, 5$	
; branch if terminal
                                     01DC   282                                 
       ; make descriptor
                            67   3F  01DC   283 	PUSHAW	(R7)		
; push address of output buffer
                       7E   56   3C  01DE   284 	MOVZWL	R6,-(SP)	
; push length
                            6E   DF  01E1   285 	PUSHAL	(SP)
              00000000'GF   01   FB  01E3   286 	CALLS
#1,g^LIB$PUT_OUTPUT	; 
                         16 50   E9  01EA   287 	BLBC	R0, 3$		
; branch on error
                         02 A8   3F  01ED   288 	PUSHAW	2(R8)		
; make descriptor
                            59   DD  01F0   289 	PUSHL	R9
                            68   3F  01F2   290 	PUSHAW	(R8)
                            00   DD  01F4   291 	PUSHL	#0
                         08 AE   DF  01F6   292 	PUSHAL	8(SP)
              00000000'GF   03   FB  01F9   293 	CALLS
#3,g^LIB$GET_INPUT	; get the input
                         05 50   E8  0200   294 	BLBS	R0, 1$		
; branch on success
                       52   06   D0  0203   295 3$:	MOVL	#go_away, R2	
; set as EOF
                            0A   11  0206   296 	BRB	2$
                       52   01   D0  0208   297 1$:	MOVL	#go_nowhere, R2	
; return go nowhere
                            68   B5  020B   298 	TSTW	(R8)
                            03   12  020D   299 	BNEQ	2$
                       52   00   D0  020F   300 	MOVL	#go_empty, R2
                          00FF   31  0212   301 2$:	BRW	1050$
                                     0215   302 
                       52   06   D0  0215   303 5$:	MOVL	#go_away, R2	
; Assume its end of file
                            51   D4  0218   304 	CLRL	R1		
; assume not escape
                            7E   7C  021A   305 	CLRQ	-(SP)		
; Iosb on the stack
                       50   5E   D0  021C   306 	MOVL	SP,R0
              55   00000000'8F   D0  021F   307 	MOVL	#IO$_READPROMPT,
R5
                  51   FDD6 CF   DE  0226   308 	MOVAL	TERMBUF, R1	
; set terminators
                            54   D4  022B   309 	CLRL	R4		
; set as no timeout
                       03   6C   B1  022D   310 	CMPW	(AP), #TIMARG/4	
; enough arguments for time
                            1F   19  0230   311         BLSS	100$		
; branch if no
                    54   0C BC   D0  0232   312 	MOVL	@TIMARG(AP), R4	
; get the time argument
                            19   13  0236   313 	BEQL	100$		
; if eql then not timed
           00 55   00000000'8F   E2  0238   314 	BBSS	#IO$V_TIMED, R5,
80$	; set tas timed.

MU_TRMIO                                                                
12-MAY-1997 16:43:05  VAX MACRO V5.4-3            Page   8
                                                                        
27-AUG-1993 17:16:41  [SOURCE.MENU]TERMIO.MAR;22        (5)

                       04   6C   B1  0240   315 80$:	CMPW	(AP), #CLTARG/4	
; enough args for clear type ahead ?
                            0C   19  0243   316 	BLSS	100$		
; if LSS no
                      08 10 BC   E9  0245   317 	BLBC	@CLTARG(AP),
100$	; branch if not to clear.
           00 55   00000000'8F   E2  0249   318 	BBSS	#IO$V_PURGE, R5,
100$	; set to purge type ahead.
                       05   6C   B1  0251   319 100$:	CMPW	(AP), #ECHOARG/4
; check for no_echo arg
                            0D   19  0254   320 	BLSS	102$		
; branch if no
                         14 BC   95  0256   321 	TSTB	@ECHOARG(AP)
                            08   13  0259   322 	BEQL	102$		
; if eql then echo is on
           EE 55   00000000'8F   E2  025B   323 	BBSS	#IO$V_NOECHO,
R5, 100$	; set to purge type ahead.
                                     0263   324   	.SHOW	MEB
                                     0263   325 102$:	$QIOW_S	-		
; Issue read, no terminators
                                     0263   326 		EFN = #1,-
                                     0263   327 		FUNC = R5,-
                                     0263   328 		IOSB = (R0),-
                                     0263   329 		CHAN = CHAN,-
                                     0263   330 		P1=2(R8),-	
; address of input buffer
                                     0263   331 		P2=R9,-		
; size of input buffer
                                     0263   332 		P3=R4,-		
; timeout 
                                     0263   333 		P4=R1,-		
; address of terminator mask
                                     0263   334 		P5=R7,-		
; address of prompt buffer
                                     0263   335 		P6=R6		
; length of prompt buffer
                            56   DD  0263       		PUSHL	R6
                            57   DD  0265       		PUSHL	R7
                            51   DD  0267       		PUSHL	R1
                            54   DD  0269       		PUSHL	R4
                            59   DD  026B       		PUSHL	R9
                         02 A8   9F  026D       		PUSHAB	2(R8)
                            7E   7C  0270       		CLRQ	-(SP)
                            60   9F  0272       		PUSHAB	(R0)
                       7E   55   3C  0274       		MOVZWL	R5,-(SP)
              7E   0000001C'EF   3C  0277       		MOVZWL
CHAN,-(SP)
                            01   DD  027E       		PUSHL	#1
              00000000'GF   0C   FB  0280       		CALLS
#12,G^SYS$QIOW
                                     0287   336 ;;;	BLBC	R0, 1020$	
; if LBC fails
                                     0287   337   	TEST_AND_BR_ON_FAIL  R0,
1020$, 3000$
                         17 50   E8  0287         	BLBS	R0, 30002$
                            50   DD  028A       	PUSHL	R0
                            6E   DF  028C         	PUSHAL	(SP)
                   00000347'EF   3F  028E         	PUSHAW	3000$
              00000000'GF   02   FB  0294         	CALLS	#2,
g^LG_SS_ELOGIT
                            50 8ED0  029B         	POPL	R0
                          0065   31  029E         	BRW	1020$
                                     02A1       30002$:
                                     02A1   338   	.NOSHOW	MEB
                       50   6E   3C  02A1   339 	MOVZWL	(SP), R0	
; Check the IOSB - may fail then
                       52   0B   D0  02A4   340 	MOVL	#go_timed, R2	
; assume timed out.
                  0000'8F   50   B1  02A7   341 	CMPW	R0, #SS$_TIMEOUT
; timed out ?
                            58   13  02AC   342 	BEQL	1020$		
; if EQL yes
                       52   06   D0  02AE   343 	MOVL	#go_away, R2	
; assume fail - eof.
                         52 50   E9  02B1   344 	BLBC	R0, 1020$	
; if LBC fail
                       52   01   D0  02B4   345 	MOVL	#go_nowhere, R2	
; assume its normal
                    51   02 AE   3C  02B7   346 	MOVZWL	2(SP), R1	
; get offset to terminator
                       51   58   C0  02BB   347 	ADDL	R8, R1
                       51   02   C0  02BE   348 	ADDL	#2, R1
                  50   FD43 CF   9E  02C1   349 	MOVAB	ONETERMS, R0
                    01   06 AE   B1  02C6   350 	CMPW	6(SP), #1	
; normal terminator length ?
                            3A   19  02CA   351 	BLSS	1020$		
; if LSS buffer full

MU_TRMIO                                                                
12-MAY-1997 16:43:05  VAX MACRO V5.4-3            Page   9
                                                                        
27-AUG-1993 17:16:41  [SOURCE.MENU]TERMIO.MAR;22        (5)

                            28   13  02CC   352 	BEQL	900$		
; if EQL 1 character
                                     02CE   353 				
; else escape sequence.
                            51   D6  02CE   354 	INCL	R1		
; point past escape
                  50   FD3C CF   9E  02D0   355 	MOVAB	TWOTERMS, R0
                    02   06 AE   B1  02D5   356 	CMPW	6(SP), #2	
; 2 char escape sequence ?
                            1B   13  02D9   357 	BEQL	900$		
; if EQL yes
                    05   06 AE   B1  02DB   358   	CMPW	6(SP), #5	
; is it 5 char esc sequence ?
                            08   12  02DF   359   	BNEQ	800$		
; no, so jump to compare chars
                    5B 8F   81   91  02E1   360 	CMPB	(R1)+, #^A"["	
; possibles are <ESC>[?
                            39   13  02E5   361 	BEQL	1900$		
; if EQL compare chars
                            1D   11  02E7   362   	BRB	1020$		
; must be 5 char unknown, give up
                                     02E9   363 
                    5B 8F   81   91  02E9   364 800$:	CMPB	(R1)+, #^A"["	
; possibles are <ESC>[?
                            07   13  02ED   365 	BEQL	900$		
; if EQL possible
                 4F 8F   FF A1   91  02EF   366 	CMPB	-1(R1),#^A"O"	
; and <ESC>O?
                            10   12  02F4   367 	BNEQ	1020$		
; if NEQ bad
                       60   61   91  02F6   368 900$:	CMPB	(R1), (R0)	
; match ?
                            07   13  02F9   369 	BEQL	920$		
; if EQL found
                       50   02   C0  02FB   370 	ADDL	#2,R0
                            60   95  02FE   371 	TSTB	(R0)
                            F4   12  0300   372 	BNEQ	900$
                    52   01 A0   9A  0302   373 920$:	MOVZBL	1(R0), R2	
; get the code.
                                     0306   374 ;
                    68   02 AE   B0  0306   375 1020$:	MOVW	2(SP), (R8)	
; return the length read.
                            08   12  030A   376 	BNEQ	1050$		
; if NEQ something there
                       01   52   91  030C   377 	CMPB	R2, #go_nowhere	
; going anywhere ?
                            03   12  030F   378 	BNEQ	1050$		
; if NEQ yes
                       52   00   D0  0311   379 	MOVL	#go_empty, R2
              51   00000022'GF   DE  0314   380 1050$:	MOVAL	g^RETURNS, R1
                     50   6142   9A  031B   381 	MOVZBL	(R1)[R2], R0	
; return the type
                                 04  031F   382 	RET
                                     0320   383 
                  50   FCFE CF   9E  0320   384 1900$:	MOVAB	FOURTERMS, R0	
;			 { MAL272 vvv }
                       60   61   91  0325   385 1901$:	CMPB	(R1), (R0)	
; first char match?
                            0E   12  0328   386   	BNEQ	1910$		
; didn't match
                 01 A0   01 A1   91  032A   387   	CMPB	1(R1), 1(R0)	
; second character match
                            07   12  032F   388   	BNEQ	1910$		
; didn't match
                 02 A0   02 A1   91  0331   389   	CMPB	2(R1), 2(R0)	
; third char match
                            09   13  0336   390   	BEQL	1920$		
; did match
                       50   04   C0  0338   391 1910$:	ADDL	#4, R0		
; no match try next entry in the table
                            60   95  033B   392   	TSTB	(R0)		
; end of table?
                            E6   12  033D   393   	BNEQ	1901$		
; not end, loop back
                            C5   13  033F   394   	BEQL	1020$		
; no match give up
                    52   03 A0   9A  0341   395 1920$:	MOVZBL	3(R0), R2	
; matches!! return code	{ MAL272 ^^^ }
                            BF   11  0345   396   	BRB	1020$		
; matched so return
                                     0347   397 ;
                                     0347   398 3000$:	PASSTRING
<"Mu_prmptrd - the QIO failed. ">
                                     0366   399 	.END

MU_TRMIO                                                                
12-MAY-1997 16:43:05  VAX MACRO V5.4-3            Page  10
Symbol table                                                            
27-AUG-1993 17:16:41  [SOURCE.MENU]TERMIO.MAR;22        (5)

$$$ADR                         = 00000060    D            IO$_READPROMPT        
          ********   X   03        
$$T1                           = 00000001    D            IO$_SENSEMODE         
          ********   X   03        
ASC_CR                         = 0000000D    D            IO$_SETMODE           
          ********   X   03        
ASC_EOF                        = 0000001A    D            LG_SS_ELOGIT          
          ********   X   03        
ASC_ESC                        = 0000001B    D            LIB$GET_INPUT         
          ********   X   03        
ASC_FF                         = 0000000C    D            LIB$PUT_OUTPUT        
          ********   X   03        
ASC_LF                         = 0000000A    D            MU_EXHAN              
          0000017E R  D  03        
ASC_TAB                        = 00000009    D            MU_PRMPTRD            
          000001AF RG D  03        
ASC_VT                         = 0000000B    D            MU_TINIT              
          00000031 RG D  03        
BUARG                          = 00000008    D            ONETERMS              
          00000008 R  D  03        
CHAN                             0000001C R  D  02        PFVARG                
        = 00000004    D            
CLTARG                         = 00000010    D            RETURNS               
          00000022 R  D  02        
DC$_TERM                       = 00000042    D            SS$_TIMEOUT           
          ********   X   03        
DESBLK                           00000000 R  D  02        SYS$ASSIGN            
          ********  GX   03        
DEVNAM                           00000028 R  D  03        SYS$DASSGN            
          ********  GX   03        
DEVNAM_L                       = 00000009    D            SYS$DCLEXH            
          ********  GX   03        
DT$_VT100                      = 00000060    D            SYS$GETDVI            
          ********  GX   03        
DT$_VT52                       = 00000040    D            SYS$QIOW              
          ********  GX   03        
DVI$_DEVCLASS                  = 00000004    D            SYS$WAITFR            
          ********  GX   03        
ECHOARG                        = 00000014    D            TERMBUF               
          00000000 R  D  03        
EST                              00000010 R  D  02        TERMCHR               
          00000014 R  D  02        
FCBOFF                         = 0000000C    D            TIMARG                
        = 0000000C    D            
FCBRECBEG                      = FFFFFFE8    D            TT$V_ESCAPE           
          ********   X   03        
FCBRECCUR                      = FFFFFFEC    D            TWOTERMS              
          00000010 R  D  03        
FOURTERMS                        00000022 R  D  03        TYPE                  
          0000001E R  D  02        
GO_AWAY                        = 00000006    D            TYPE2                 
          00000020 R  D  02        
GO_EAST                        = 00000004    D            
GO_EMPTY                       = 00000000    D            
GO_F10                         = 00000010    D            
GO_F11                         = 00000011    D            
GO_F12                         = 00000012    D            
GO_F13                         = 00000013    D            
GO_F14                         = 00000014    D            
GO_F15                         = 00000015    D            
GO_F16                         = 00000016    D            
GO_F17                         = 00000017    D            
GO_F18                         = 00000018    D            
GO_F19                         = 00000019    D            
GO_F20                         = 0000001A    D            
GO_F6                          = 0000000C    D            
GO_F7                          = 0000000D    D            
GO_F8                          = 0000000E    D            
GO_F9                          = 0000000F    D            
GO_LENGTH                      = 0000000D    D            
GO_MAX                         = 0000000C    D            
GO_NORTH                       = 00000002    D            
GO_NOWHERE                     = 00000001    D            
GO_PF1                         = 00000007    D            
GO_PF2                         = 00000008    D            
GO_PF3                         = 00000009    D            
GO_PF4                         = 0000000A    D            
GO_SOUTH                       = 00000003    D            
GO_TIMED                       = 0000000B    D            
GO_WEST                        = 00000005    D            
IO$V_NOECHO                      ********   X   03        
IO$V_PURGE                       ********   X   03        
IO$V_TIMED                       ********   X   03        

MU_TRMIO                                                                
12-MAY-1997 16:43:05  VAX MACRO V5.4-3            Page  11
Psect synopsis                                                          
27-AUG-1993 17:16:41  [SOURCE.MENU]TERMIO.MAR;22        (5)


                                                +----------------+
                                                ! Psect synopsis !
                                                +----------------+

PSECT name                      Allocation          PSECT No.  Attributes     
----------                      ----------          ---------  ----------     
.  ABS  .                       00000000  (    0.)  00 (  0.)  NOPIC   USR   CON
  ABS   LCL NOSHR NOEXE NORD  NOWRT NOVEC BYTE  
$ABS$                           00000000  (    0.)  01 (  1.)  NOPIC   USR   CON
  ABS   LCL NOSHR   EXE   RD    WRT NOVEC BYTE  
$LOCAL                          0000002F  (   47.)  02 (  2.)    PIC   USR   CON
  REL   LCL NOSHR NOEXE   RD    WRT NOVEC LONG  
$CODE                           00000366  (  870.)  03 (  3.)    PIC   USR   CON
  REL   LCL   SHR   EXE   RD  NOWRT NOVEC LONG  

                                             +------------------------+
                                             ! Performance indicators !
                                             +------------------------+

Phase                    Page faults    CPU Time       Elapsed Time   
-----                    -----------    --------       ------------   
Initialization                   37     00:00:00.02    00:00:00.10
Command processing              854     00:00:00.11    00:00:00.36
Pass 1                          465     00:00:00.63    00:00:01.27
Symbol table sort                 1     00:00:00.07    00:00:00.07
Pass 2                           33     00:00:00.16    00:00:00.57
Symbol table output               1     00:00:00.00    00:00:00.00
Psect synopsis output             2     00:00:00.01    00:00:00.14
Cross-reference output            0     00:00:00.00    00:00:00.00
Assembler run totals           1399     00:00:01.00    00:00:02.52

The working set limit was 1950 pages.
48055 bytes (94 pages) of virtual memory were used to buffer the intermediate
code.
There were 50 pages of symbol table space allocated to hold 754 non-local and 28
local symbols.
399 source lines were read in Pass 1, producing 56 object records in Pass 2.
28 pages of virtual memory were used to define 25 macros.

                                            +--------------------------+
                                            ! Macro library statistics !
                                            +--------------------------+

Macro library name                           Macros defined      
------------------                           --------------      
TOTE_MAL:[SHARED]TOTELIB.MLB;1                          1        
SYS$COMMON:[SYSLIB]STARLET.MLB;2                       15        
TOTALS (all libraries)                                 16        

933 GETS were required to define 16 macros.

There were no errors, warnings or information messages.

MACRO/OBJ=TERMIO/LIST=TERMIO/DEBUG TERMIO+[SHARED]TOTELIB/LIB

T.RTitleUserPersonal
Name
DateLines
2673.1TLE::REAGANAll of this chaos makes perfect senseTue May 13 1997 14:5020
    Gee, now I've seen everything.
    
    As you can guess, doing this is unsupported and subject to change
    at any time.  Guess what?  It has!
    
    In OpenVMS Alpha V6.1 and V6.2, the "magic" numbers are -44/-40.
    In OpenVMS Alpha V7.0, they are -48/-44 and with OpenVMS V7.1,
    they are -56/-52.
    
    In addition, I found a major bug in SDL between OpenVMS V6.2
    and V7.0.  The numbers should have also been -44/-40 in V7.0
    and -52/-48 in V7.1.  So when I go QAR it and it gets fixed,
    the numbers will change again.
    
    Alternatively, the way to do this is open OUTPUT explicitly
    with CARRIAGE_CONTROL := NONE.  That way, WRITELN does just
    a buffer flush with no added cr,lf.  If you want carriage
    returns or line feeds, you have to write them out explicitly.
    
    				-John
2673.2TLE::REAGANAll of this chaos makes perfect senseWed May 14 1997 13:349
    I remember something last night.  Besides getting new RTLs
    with OpenVMS Alpha, the Pascal kit has also provided new RTLs
    on occasion.  There is a chance that an OpenVMS V6.1 system could
    have a PAS$RTL.EXE that came with the compiler kit with the "magic"
    numbers that aren't -44/-40.  So if the customer thinks they can
    decide the numbers based on the OpenVMS version, that won't work
    either.  
    
    				-John
2673.3AUSS::GARSONDECcharity Program OfficeWed May 14 1997 22:555
    re .2
    
    I don't suppose there is an undocumented PAS$ routine that does the
    flush. It would still be unsupported to call it but better than hard
    coding offsets into data structures. ??
2673.4TLE::REAGANAll of this chaos makes perfect senseThu May 15 1997 13:318
    Nope.  There is no undocumented routine to flush the buffer.  The
    documented routine to flush the buffer is WRITELN.  If you don't
    the implicit cr/lf that RMS adds, open the file with CARRIAGE_CONTROL
    set to NONE.   The Pascal RTL does not add the cr/lf.  What RMS routine
    could we call to flush the buffer without carriage control if the
    file has it set?
    
    				-John