From:	CSBVAX::MRGATE!@KL.SRI.Com:nagy%warner.hepnet@Lbl.Arpa@SMTP 20-AUG-1987 08:18
To:	EVERHART
Subj:	Modified SWING modules to allow use as a foreign DCL command

Received: from Lbl.Arpa by KL.SRI.COM with TCP; Thu 20 Aug 87 04:38:24-PDT
Received: from warner.HepNet by Lbl.Gov with VMSmail ;
	Thu, 20 Aug 87 04:31:07 PDT
Date:    Thu, 20 Aug 87 04:31:07 PDT
From:     nagy%warner.hepnet@Lbl.Arpa
Message-Id: <870820043107.02b@Lbl.Arpa>
Subject: Modified SWING modules to allow use as a foreign DCL command
To:       Info-VAX@kl.sri.com
X-ST-Vmsmail-To: INFO_VAX

The following VMS_SHAR file contains a modified version of SWING.FOR,
the main program module for the recently distributed version of SWING,
and SWINGTABLES.CLD, my version of the DCL command tables for SWING.

I have made some modifications so that this version of SWING can be
defined as a foreign DCL command since the definition

	$ SWING :== $disk:[directory]SWING

is a LOT faster to execute than

	$ SET COMMAND disk:[directory]SWINGTABLES

and is easier on system resources (memory).  I have submitted an article
to the PageSwapper describing how to make this change in general and why
it is a good thing to do.  I have written several utilities which are
defined as foreign commands but which have DCL command syntax and use
the CLI$ routines to decode the command line (using the DCL parser makes
it very easy to write such things).  I have also modified some utilities
from past VAX SIG tapes in the same manner.

Anyway, unpack the SHAR file, compile the modules and add to the library
and relink:

	$ FORTRAN SWING
	$ SET COMMAND/OBJECT  SWINGTABLES	!Makes .OBJ file
	$ LIBRARY  SWING  SWING,SWINGTABLES
	$ LINK/EXECUTABLE=SWING  SWING/LIBRARY/INCLUDE=SWING


........................ Cut between dotted lines and save ......................
$!..............................................................................
$! VAX/VMS archive file created by VMS_SHAR V-4.04 12-Aug-1987
$! which was written by Michael Bednarek (U3369429@ucsvc.dn.mu.oz.au)
$! To unpack, simply save and execute (@) this file.
$!
$! This archive was created by NAGY
$!      on Thursday 20-AUG-1987 06:31:14.61
$!
$! It contains the following 2 files:
$! SWING.FOR SWINGTABLES.CLD
$!=============================================================================

$ Set Symbol/Scope=(NoLocal,NoGlobal)
$ Version=F$GetSYI("VERSION") ! See what VMS version we have here:
$ If Version.ges."V4.4" then goto Version_OK
$ Write SYS$Output "Sorry, you are running VMS ",Version, -
                ", but this procedure requires V4.4 or higher."
$ Exit 44
$Version_OK: CR[0,8]=13
$ Pass_or_Failed="failed!,passed."
$ Goto Start
$Convert_File:
$ Read/Time_Out=0/Error=No_Error1/Prompt="creating ''File_is'" SYS$Command ddd
$No_Error1: Define/User_Mode SYS$Output NL:
$ Edit/TPU/NoSection/NoDisplay/Command=SYS$Input/Output='File_is' -
        VMS_SHAR_DUMMY.DUMMY
f:=Get_Info(Command_Line,"File_Name");b:=Create_Buffer("",f);
o:=Get_Info(Command_Line,"Output_File");Set (Output_File,b,o);
Position (Beginning_of(b));Loop x:=Erase_Character(1); Loop ExitIf x<>"V";
Move_Vertical(1);x:=Erase_Character(1);Append_Line;Move_Horizontal
(-Current_Offset);EndLoop;Move_Vertical(1);ExitIf Mark(None)=End_of(b)
EndLoop;Exit;
$ Delete VMS_SHAR_DUMMY.DUMMY;*
$ Checksum 'File_is
$ Success=F$Element(Check_Sum_is.eq.CHECKSUM$CHECKSUM,",",Pass_or_Failed)+CR
$ Read/Time_Out=0/Error=No_Error2/Prompt=" CHECKSUM ''Success'" SYS$Command ddd
$No_Error2: Return
$Start:
$ File_is="SWING.FOR"
$ Check_Sum_is=1195880454
$ Copy SYS$Input VMS_SHAR_DUMMY.DUMMY
X*=======================================================================
X*
X*  Title:        SWING
X*
X*  Version:      1-001
X*
X*  Abstract:     SWING is a VMS utility for displaying and manipulating
X*                VMS directory trees.
X*
X*  Environment:  VMS
X*
X*  Author:       Eric Andresen of General Research Corporation
X*
X*  Date:         24-SEP-1986
X*
X*-----------------------------------------------------------------------
X*
X*  Modified and
X*  Expanded by:  Craig Young of Hughes Aircraft Company
X*
X*  Additions:    The main addition was the FILER and all the subroutines
X*                which support it.  The DCL Command option was added to
X*                the SWING command menu.  Changes were made to subroutine
X*                Load_Nodes to support '<' and '>' as directory indica-
X*                tors, to allow the Master file directory as the root
X*                directory and to allow the START qualifier.
X*
X*  Date:         3-AUG-1987
X*
X*-----------------------------------------------------------------------
X*
X*  Modified by:  Frank J Nagy of Fermilab
X*
X*  Changes:      Modified main routine to pick up command line as foreign
X*                command, add the SWING verb and parse it with DCL so that
X*                the /START qualifier can be checked for.
X*
X*  Date:         16-AUG-1987
X*
X*-----------------------------------------------------------------------
X
X      program swing
X
X      include 'swing.cmn'
X      include '($smgdef)'
X
X      integer    ii, jj, istat
X      integer    ikey, old_level, old_line, isave, code, code_type
X      integer    smg$create_virtual_display
X      logical    crt, finished
X      character  key, choice*(PD_MAX_CHOICE_LEN)
X
X      External  Swing_Tables
X      Integer*4 Lib$Get_Foreign, Cli$Dcl_Parse, Lib$Get_Input, sts
X      Character*255 CmdLine
X      Integer*2 CL_Len
X
XC
XC Get the Foreign Command line, tack the verb onto the front and
XC invoke the DCL command processor on the result.
XC
X      sts = Lib$Get_Foreign( CmdLine,, CL_Len)
X      IF (.NOT. sts) CALL Lib$Signal( %VAL(sts))
X      IF (CL_Len .gt. 0) Then
X          sts = Cli$Dcl_Parse( 'SWING '//CmdLine(1:CL_Len),
X     1                          Swing_Tables, Lib$Get_Input)
X      Else
X          sts = Cli$Dcl_Parse( 'SWING ', Swing_Tables, Lib$Get_Input)
X      EndIf
X      IF (.NOT. sts) CALL Exit
X
X      if ( .not. crt() )
X     .   call print_message( 'You must use a DEC CRT terminal', 1 )
X
X      call define_paste_board
X
Xc     CREATE THE WINDOWS
X
X      istat = smg$create_virtual_display(  1, 132, window1 )
X      istat = smg$create_virtual_display(  MAX_LINES, 132, window2 )
X      istat = smg$create_virtual_display(  2, 132, window3 )
X      istat = smg$create_virtual_display(  12, 25, file_window )
X      call smg$set_display_scroll_region(  file_window )
X      istat = smg$create_virtual_display(  15, 70, DCL_window )
X      call smg$set_display_scroll_region(  DCL_window )
X
X      call load_nodes
X      call define_smg_layout
X      call load_display
X      call draw_screen
X
X      proc_created = 0
X
X      do while ( .not. finished )
X
X         call smg$read_keystroke( keyboard, ikey )
X
X         call print_message( ' ', 0 )
X
X         old_line = cur_line
X         old_level = cur_level
X         old_rend = node(node_num).rend
X
X         code_type = 0
X         code = 0
X
X         if ( ikey .eq. smg$k_trm_do .or.
X     .        ikey .eq. smg$k_trm_ctrlp ) then
X            if ( avo ) then
X               call pd_get_choice( board_id, keyboard, width,
X     .                             pull_choices, choice, code )
X               code_type = code / 10
X            else
X               call print_message( 'Advanced video option required', 0 )
X               end if
X            end if
X
X         if ( ikey .eq. smg$k_trm_ctrlz .or.
X     .        ikey .eq. smg$k_trm_lowercase_x .or.
X     .        ikey .eq. smg$k_trm_uppercase_x .or.
X     .        ikey .eq. smg$k_trm_lowercase_e .or.
X     .        ikey .eq. smg$k_trm_uppercase_e .or.
X     .        ikey .eq. smg$k_trm_enter .or.
X     .        code .eq. 91 ) then
X            finished = .true.
X
X            else if ( ikey .eq. smg$k_trm_up ) then
X            ii = cur_level
X            jj = cur_line - 1
X            do while( jj .ge. 1 .and. node_pointer(ii,jj) .eq. 0 )
X               jj = jj - 1
X            end do
X            if ( jj .ge. 1 ) cur_line = jj
X            call update_screen( old_line, old_level )
X
X            else if ( ikey .eq. smg$k_trm_down ) then
X            ii = cur_level
X            jj = cur_line + 1
X            do while( node_pointer(ii,jj) .eq. 0 .and.jj .le. num_lines)
X               jj = jj + 1
X            end do
X            if ( jj .le. num_lines ) cur_line = jj
X            call update_screen( old_line, old_level )
X
X            else if ( ikey .eq. smg$k_trm_right ) then
X            ii = cur_level + 1
X            jj = cur_line
X            do while( node_pointer(ii,jj) .eq. 0 .and.ii.le. MAX_LEVELS)
X               ii = ii + 1
X            end do
X            if ( ii .le. MAX_LEVELS ) cur_level = ii
X            call update_screen( old_line, old_level )
X
X            else if ( ikey .eq. smg$k_trm_left .and.
X     .                cur_level .ge. 1 ) then
X            ii = cur_level - 1
X            jj = cur_line
X            do while( node_pointer(ii,jj) .eq. 0 .and. jj .ge. 1 )
X               jj = jj - 1
X            end do
X            if ( jj .ge. 1 ) then
X               cur_level = ii
X               cur_line = jj
X               end if
X            call update_screen( old_line, old_level )
X
X            else if ( ikey .eq. smg$k_trm_lowercase_b .or.
X     .                ikey .eq. smg$k_trm_uppercase_b ) then
X            ii = MAX_LEVELS
X            cur_line = num_lines
X            do while( node_pointer(ii,cur_line) .eq. 0 .and. ii .ge. 1 )
X               ii = ii - 1
X            end do
X            cur_level = ii
X            call update_screen( old_line, old_level )
X
X            else if ( ikey .eq. smg$k_trm_lowercase_t .or.
X     .                ikey .eq. smg$k_trm_uppercase_t ) then
X            cur_line = 1
X            cur_level = 0
X            call update_screen( old_line, old_level )
X
X            else if ( code_type .eq. 1 .or.
X     .                ikey .eq. smg$k_trm_lowercase_c .or.
X     .                ikey .eq. smg$k_trm_uppercase_c ) then
X            call create_directory( code )
X
X            else if ( code_type .eq. 2 .or.
X     .                ikey .eq. smg$k_trm_lowercase_r .or.
X     .                ikey .eq. smg$k_trm_uppercase_r ) then
X            call rename_directory( 20 )
X
X            else if ( code_type .eq. 3 .or.
X     .                ikey .eq. smg$k_trm_lowercase_m .or.
X     .                ikey .eq. smg$k_trm_uppercase_m ) then
X            call rename_directory( 30 )
X
X            else if ( code_type .eq. 4 .or.
X     .                ikey .eq. smg$k_trm_lowercase_d .or.
X     .                ikey .eq. smg$k_trm_uppercase_d ) then
X            call delete_directory( code )
X
X            else if ( code_type .eq. 5 .or.
X     .                ikey .eq. smg$k_trm_lowercase_p .or.
X     .                ikey .eq. smg$k_trm_uppercase_p ) then
X            call hardcopy( code )
X
X            else if ( code_type .eq. 6 .or.
X     .                ikey .eq. smg$k_trm_lowercase_s .or.
X     .                ikey .eq. smg$k_trm_uppercase_s ) then
X            call record_structure( .true. )
X
X            else if ( code_type .eq. 7 .or.
X     .                ikey .eq. smg$k_trm_lowercase_o .or.
X     .                ikey .eq. smg$k_trm_uppercase_o ) then
X            call change_options( code )
X
X            else if ( code_type .eq. 8 .or.
X     .                ikey .eq. smg$k_trm_pf2 .or.
X     .                ikey .eq. smg$k_trm_help .or.
X     .                ikey .eq. smg$k_trm_lowercase_h .or.
X     .                ikey .eq. smg$k_trm_uppercase_h ) then
X            call help( code )
X            end if
X
X         call smg$set_cursor_abs( window2, cur_line, cur_level*17+1 )
X
X      end do
X
X      call exit_swing
X      end
$ GoSub Convert_File
$ File_is="SWINGTABLES.CLD"
$ Check_Sum_is=1029839912
$ Copy SYS$Input VMS_SHAR_DUMMY.DUMMY
XModule Swing_Tables
XIdent "V1.0"
XDefine Verb  SWING
X      Qualifier  START, Placement=Global, Nonnegatable, Value(Default=Current)
$ GoSub Convert_File
$ Exit

= Frank J. Nagy   "VAX Guru"
= Fermilab Research Division EED/Controls
= HEPNET: WARNER::NAGY (43198::NAGY) or FNAL::NAGY (43009::NAGY)
= BitNet: NAGY@FNAL
= USnail: Fermilab POB 500 MS/220 Batavia, IL 60510
