C*****************************************************************************
C  TAG/UNTAG routines  (Include & Exclude)
C  Revisions (Version 6.x)            August, 1986
C	Dale E. Coy
C	Los Alamos National Laboratory
C	(505) 667-7159
C
C*****************************************************************************
C-----------------------------------------------------------------C
C Include a file for - Printing                                   C
C                    - Copying                                    C
C                    - Deleting                                   C
C Put the file that the cursor is beside into the 'INCLUD' array  C
C and put a symbol on the CRT.  				  C
C-----------------------------------------------------------------C
       Subroutine Include
       Implicit Integer*4 (A - Z)
       Include 'Common.Dat'
C-----------------------------------------------------------------C

	If (IncluCount .GE. Max_Tags) then
		Call Mess_Wait 
	1	(' You have reached the limit of Tagged files. '//
	2	 ' This file can''t be Tagged.')
		Return
	End If


	Call SMG$Read_From_Display (Files_Display,TempName
	1		,,Current_Line)
        If (TempName(Name_Pos:Name_Pos) .EQ. ' ') GoTo 100

        If (TempName(Flag_Pos:Flag_Pos) .NE. Tag_Char) then

        	Call SMG$Put_Chars (Files_Display,Tag_Char,
	1		Current_Line,Flag_Pos,,SMG$M_Bold)
	   
        	IncluCount = IncluCount + 1 ! Bump include file count
        	If (IncluCount .LE. 1) IncluCount = 1 ! Insurance
        	IncluLines(IncluCount) = Current_Line
        	Do I = IncluCount - 1, 1, -1
        		If (IncluLines(I) .GT. Current_Line) Then 
			        IncluLines(I + 1) = IncluLines(I)
               			IncluLines(I) = Current_Line
	     		Else
	       			GoTo 100		
             		End If
           	End Do
       End If

100    Return 
       End

C-----------------------------------------------------------------C
C Exclude Utility:                                                C
C Undo the exclude.  Take the file name out of the 'INCLU' array  C
C and take the symbol from the files array.                       C
C-----------------------------------------------------------------C
       Subroutine Exclude
       Implicit Integer*4 (A - Z)
       Include 'Common.Dat'
C-------------------------------------------------------------------C

	Call SMG$Read_From_Display (Files_Display,TempName
	1		,,Current_Line)

        If (TempName(Flag_Pos:Flag_Pos) .EQ. Tag_Char) then

           	Call SMG$Erase_Chars (Files_Display,1,Current_Line,
	1		Flag_Pos)
	   
           	Tx = 0  !index of target name
           	Do I = 1, IncluCount       ! insure target is in array
             		If (IncluLines(I) .EQ. Current_Line) then
       		  		Tx = I
		  		GoTo 100
	     		End If	
           	End Do

100        	If (Tx .NE. 0) then            ! take target out of array
             		Do I = Tx, IncluCount - 1
               			IncluLines(I) = IncluLines(I + 1)
             		End Do

             		IncluLines(IncluCount) = 0   ! for debug purposes
             		IncluCount = IncluCount - 1  ! decrement array count

             		If (IncluCount .LT. 0) IncluCount = 0 ! Insurance
	        End If
        End If


        Return 
        End
       
