HP OpenVMS Systemsask the wizard |
The Question is: Can you provide me with an example on how to use the SMG Key definition to enable the TAB key as a terminating character. I'm programing in Fortran. The Answer is :
Assuming you're reading using SMG$READ_STRING, the following program
defines a "short form" terminator mask which specifies TAB, CR, ^Z and ESC
as terminators.
C COPYRIGHT (C) 1994 BY
C DIGITAL EQUIPMENT CORPORATION, MAYNARD
C MASSACHUSETTS. ALL RIGHTS RESERVED.
C THIS SOFTWARE IS FURNISHED UNDER A LICENSE AND MAY BE USED AND COPIED
C ONLY IN ACCORDANCE WITH THE TERMS OF SUCH LICENSE AND WITH THE INCLUSION
C OF THE ABOVE COPYRIGHT NOTICE. THIS SOFTWARE OR ANY OTHER COPIES
C THEREOF MAY NOT BE PROVIDED OR OTHERWISE MADE AVAILABLE TO ANY OTHER
C PERSON. NO TITLE TO AND OWNERSHIP OF THE SOFTWARE IS HEREBY TRANSFERRED.
C THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE WITHOUT NOTICE AND
C SHOULD NOT BE CONSTRUED AS A COMMITMENT BY DIGITAL EQUIPMENT CORPORATION.
C DIGITAL ASSUMES NO RESPONSIBILITY FOR THE USE OR RELIABILITY OF ITS
C SOFTWARE ON EQUIPMENT THAT IS NOT SUPPLIED BY DIGITAL.
C NO RESPONSIBILITY IS ASSUMED FOR THE USE OR RELIABILITY OF SOFTWARE
C ON EQUIPMENT THAT IS NOT SUPPLIED BY DIGITAL EQUIPMENT CORPORATION.
C SUPPORT FOR THIS SOFTWARE IS NOT COVERED UNDER ANY DIGITAL SOFTWARE
C PRODUCT SUPPORT CONTRACT, BUT MAY BE PROVIDED UNDER THE TERMS OF THE
C CONSULTING AGREEMENT UNDER WHICH THIS SOFTWARE WAS DEVELOPED.
program simple_read_string
implicit none
integer*4 smg$create_pasteboard,
1 smg$create_virtual_display,
2 smg$create_virtual_keyboard,
3 smg$label_border,
4 smg$paste_virtual_display,
5 smg$read_string,
6 smg$put_line
integer*4 pbid, vdid, kbid, stat
integer*4 termmask(2)
integer*2 tcode, res_len
character*76 out_line
character*20 res_string
character*10 tcode_str, stat_str
10 format (i10)
!
! Initialize variables...
!
pbid = 0
vdid = 0
kbid = 0
stat = 0
tcode = 0
res_len = 0
termmask(1) = 0
termmask(2) = 0
termmask(2) = IBSET(termmask(2),9) ! TAB
termmask(2) = IBSET(termmask(2),13) ! CR
termmask(2) = IBSET(termmask(2),26) ! ^Z
termmask(2) = IBSET(termmask(2),27) ! ESC
C Add further lines like the above to define other ASCII characters in
C the range 0-31 as terminators. Second parameter to IBSET is the ASCII
C code of the new terminator.
out_line = ' '
res_string = ' '
tcode_str = ' '
stat_str = ' '
!
! Set up SMG pasteboard, keyboard, display, etc...
!
stat = smg$create_pasteboard (pbid)
if (.not. stat) call lib$stop (%val(stat))
stat = smg$create_virtual_keyboard (kbid)
if (.not. stat) call lib$stop (%val(stat))
stat = smg$create_virtual_display (22, 78, vdid)
if (.not. stat) call lib$stop (%val(stat))
out_line = ' Press keys, terminators, CTRL/Z, etc., Q=Quit '
stat = smg$label_border (vdid, out_line(1:47))
if (.not. stat) call lib$stop (%val(stat))
stat = smg$paste_virtual_display (vdid, pbid, 2, 2)
if (.not. stat) call lib$stop (%val(stat))
!
! Loop until Q is entered...
!
res_string = ' '
do while (res_string(1:1) .ne. 'Q')
res_string = ' '
res_len = 0
tcode = 0
stat = smg$read_string (kbid, res_string,, 20,,,
1 termmask,
2 res_len, tcode, vdid)
!
! Convert TCODE and STAT to string, format output line, and
! write information to virtual display.
!
write (tcode_str, 10) tcode
write (stat_str, 10) stat
out_line = 'Stat: ' // stat_str //
1 ' Tcode: ' // tcode_str //
2 ' Data: ' // res_string(1:res_len)
stat = smg$put_line (vdid, out_line)
if (.not. stat) call lib$stop (%val(stat))
enddo
end
|