      subroutine SpecPackage


      integer*2 NF, NI, NR, NC, NT, NdimT, NdimC
      integer*2 NdimH, IEle, L, I

      parameter ( NF=  2,NI=  1,NR=  1,NC=  2,NT= 14 )
      parameter ( NdimT=  101,NdimC=   18,NdimH=  124 )

      integer*2 Row, Col, StartField, TermKeys(30), LastKey
      integer*2 First, Last
      logical*1 Next, Previous, Exit, Refresh
      character*80 ScrHelpLine
      integer*2 FieldNumber
      logical*1 Valid

      character*  6 S1
      character* 12 S2

      character*1 Text(NdimT)
      character*1 Char(NdimC)
      character*1 Help(NdimH)

      character*7 Formats(NF)

      integer*2 TextTable(5,NT), FldTable(7,NF), IntArray(5,NI)
      integer*2 CharTable(2,NC), HelpTable(4,NF)
      real RealArray(5,NR) 

      data ScrHelpLine(1:40) /
     1   'Up-Previous Field           Down-Next Fi'/
      data ScrHelpLine(41:80) /
     1   'eld          ^Z-Start Test              '/

 
      data (TextTable(I,  1),I=1,5) /    1,34, 1, 1, 8/
      data (Text(I),I=    1,   34) /
     1   'l','q','q','q','q','q','q','q','q','q','q','q','q','q','q',
     1   'q','q','q','q','q','q','q','q','q','q','q','q','q','q','q',
     1   'q','q','q',
     1   'k' /
 
      data (TextTable(I,  2),I=1,5) /   35, 1, 2, 1, 8/
      data (Text(I),I=   35,   35) /
     1   'x' /
 
      data (TextTable(I,  3),I=1,5) /   36, 1, 2,34, 8/
      data (Text(I),I=   36,   36) /
     1   'x' /
 
      data (TextTable(I,  4),I=1,5) /   37, 1, 3, 1, 8/
      data (Text(I),I=   37,   37) /
     1   'x' /
 
      data (TextTable(I,  5),I=1,5) /   38,12, 3, 9, 0/
      data (Text(I),I=   38,   49) /
     1   'S','p','e','c','i','m','e','n',' ','I','D',
     1   ' ' /
 
      data (TextTable(I,  6),I=1,5) /   50, 1, 3,34, 8/
      data (Text(I),I=   50,   50) /
     1   'x' /
 
      data (TextTable(I,  7),I=1,5) /   51, 1, 4, 1, 8/
      data (Text(I),I=   51,   51) /
     1   'x' /
 
      data (TextTable(I,  8),I=1,5) /   52, 1, 4,34, 8/
      data (Text(I),I=   52,   52) /
     1   'x' /
 
      data (TextTable(I,  9),I=1,5) /   53, 1, 5, 1, 8/
      data (Text(I),I=   53,   53) /
     1   'x' /
 
      data (TextTable(I, 10),I=1,5) /   54,11, 5, 6, 0/
      data (Text(I),I=   54,   64) /
     1   'O','r','i','e','n','t','a','t','i','o',
     1   'n' /
 
      data (TextTable(I, 11),I=1,5) /   65, 1, 5,34, 8/
      data (Text(I),I=   65,   65) /
     1   'x' /
 
      data (TextTable(I, 12),I=1,5) /   66, 1, 6, 1, 8/
      data (Text(I),I=   66,   66) /
     1   'x' /
 
      data (TextTable(I, 13),I=1,5) /   67, 1, 6,34, 8/
      data (Text(I),I=   67,   67) /
     1   'x' /
 
      data (TextTable(I, 14),I=1,5) /   68,34, 7, 1, 8/
      data (Text(I),I=   68,  101) /
     1   'm','q','q','q','q','q','q','q','q','q','q','q','q','q','q',
     1   'q','q','q','q','q','q','q','q','q','q','q','q','q','q','q',
     1   'q','q','q',
     1   'j' /
 
      data (FldTable(I,    1),I=1,7) / 3,    1,1, 6, 3,21,1 /
      data (CharTable(I,    1),I=1,2) /     1,0 /
      data (HelpTable(I,    1),I=1,4) /     1,   41,    0,    0 /
      data (Help(I),I=    1,   41) /
     1   'E','n','t','e','r',' ','t','h','e',' ','S','p','e','c','i',
     1   'm','e','n',' ','I','D',' ','a','s',' ','a',' ','l','e','g',
     1   'a','l',' ','f','i','l','e','n','a','m',
     1   'e' /
      data Formats(    1) / 'A6     '/
 
      data (FldTable(I,    2),I=1,7) / 6,    2,1,12, 5,18,1 /
      data (CharTable(I,    2),I=1,2) /     7,1 /
      data (HelpTable(I,    2),I=1,4) /    42,   58,  100,   25 /
      data (Help(I),I=   42,   99) /
     1   'S','e','l','e','c','t',' ','S','p','e','c','i','m','e','n',
     1   ' ','O','r','i','e','n','t','a','t','i','o','n',' ','R','e',
     1   'l','a','t','i','v','e',' ','T','o',' ','R','o','l','l','i',
     1   'n','g',' ','D','i','r','e','c','t','i','o','n',
     1   ':' /
      data (Help(I),I=  100,  124) /
     1   'T','r','a','n','s','v','e','r','s','e',' ',' ',' ','L','o',
     1   'n','g','i','t','u','d','i','n','a',
     1   'l' /
      data Formats(    2) / 'A12    '/


      entry SpecClear( Row, Col )


      call ClearScrn( Row, Col, 34,  7 )

      return



      entry SpecTextDsp( Row, Col )

      call DsplyText( Row, Col,
     1   NT, TextTable, NdimT, Text )

      return

      entry SpecDataDsp( Row, Col, First, Last
     1, S1, S2
     1 )

 
      IEle = FldTable(2,  1)
      L = FldTable(4,  1)
      call ANtoA1( S1
     1  , NdimC, Char, CharTable(1,IEle), L )
 
      IEle = FldTable(2,  2)
      L = FldTable(4,  2)
      call ANtoA1( S2
     1  , NdimC, Char, CharTable(1,IEle), L )

      call DsplyData( Row, Col, First, Last,
     1   NF, FldTable,
     1   NI, IntArray, NR, RealArray, NC, CharTable, NdimC, Char,
     1   Formats )

      return

      entry SpecValidate( First, Last
     1, S1, S2
     1, Valid, FieldNumber )

 
      IEle = FldTable(2,  1)
      L = FldTable(4,  1)
      call ANtoA1( S1
     1  , NdimC, Char, CharTable(1,IEle), L )
 
      IEle = FldTable(2,  2)
      L = FldTable(4,  2)
      call ANtoA1( S2
     1  , NdimC, Char, CharTable(1,IEle), L )

      call VldWholeScreen( First, Last, NF, FldTable,
     1   NI, IntArray, NR, RealArray, NC, CharTable, NdimC, Char,
     1   'SPEC ', Valid, FieldNumber )

      return

      entry SpecEdit( Row, Col, First, Last, StartField, TermKeys
     1, S1, S2
     1, Next, Previous, Exit, Refresh, LastKey )

 
      IEle = FldTable(2,  1)
      L = FldTable(4,  1)
      call ANtoA1( S1
     1  , NdimC, Char, CharTable(1,IEle), L )
 
      IEle = FldTable(2,  2)
      L = FldTable(4,  2)
      call ANtoA1( S2
     1  , NdimC, Char, CharTable(1,IEle), L )

      call EditScrn( 'SPEC ', Row, Col, First, Last, StartField,
     1   ScrHelpLine, TermKeys, NF, FldTable,
     1   NI, IntArray, NR, RealArray, NC, CharTable, NdimC, Char,
     1   Formats, HelpTable, NdimH, Help, Next, Previous, Exit,
     1   Refresh, LastKey )
 
      IEle = FldTable(2,  1)
      L = FldTable(4,  1)
      call A1toAN( NdimC, Char, CharTable(1,IEle), L, 
     1  S1 )
 
      IEle = FldTable(2,  2)
      L = FldTable(4,  2)
      call A1toAN( NdimC, Char, CharTable(1,IEle), L, 
     1  S2 )

      return
      end


      integer*2 function SpecInd( Name )

      integer*2 I
      character*(*) Name
      character*32 LocName
      character*32 FldName(  2)
      data FldName(  1) /'SPECIMENID'/
      data FldName(  2) /'ORIENTATION'/

      LocName = Name
      call CvtToUpCase( LocName )
      do 100 I = 1 ,   2
        if( FldName(I) .eq. LocName ) then
          SpecInd = I
          return
        end if
100   continue

      SpecInd = 0

      end
