home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / modcomp / findln. < prev    next >
Text File  |  2020-01-01  |  6KB  |  160 lines

  1.       INTEGER FUNCTION FINDLN (LIN,APAT,A1,Z1)
  2. C
  3. C     ****************************************************************
  4. C
  5. C              KERMIT for the MODCOMP MAXIV operating system
  6. C
  7. C        Compliments of:
  8. C
  9. C                         SETPOINT, Inc.
  10. C                      10245 Brecksville Rd.
  11. C                      Brecksville, Ohio 44141
  12. C
  13. C
  14. C      KERMIT is a copyrighted protocol of Columbia Univ. The authors
  15. C      of this version hereby grant permission to copy this software
  16. C      provided that it is not used for an explicitly commercial
  17. C      purpose and that proper credit be given. SETPOINT, Inc. makes
  18. C      no warranty whatsoever regarding the accuracy of this package
  19. C      and will assume no liability resulting from it's use.
  20. C
  21. C     ****************************************************************
  22. C
  23. C     Abstract:  This function will try to find the pattern within
  24. C                a line.  It alse returns the value of where the
  25. C                pattern begins and ends.
  26. C
  27. C     MODIFICATION HISTORY
  28. C
  29. C     BY            DATE     REASON            PROGRAMS AFFECTED
  30. C
  31. C     ****************************************************************
  32. C
  33. C     Author: Bob Borgeson          Version: A.0    Date: Aug-86
  34. C
  35. C     Calling Parameters:
  36. C
  37. C     R    LIN          - Array that holds the line to search
  38. C     R    APAT         - Array that holds the pattern to search for
  39. C     R/W  A1           - Initially tells this routine where to start
  40. C                         looking for a match.  On return it tells the
  41. C                         caller where the matched pattern begins.
  42. C     W    Z1           - Tells the calling program where the matched
  43. C                         pattern ends. EOS is not counted in the Z1
  44. C                         value.
  45. C     W    FINDLN       - Function value, = YES, pattern was found,
  46. C                         = NO, pattern was not found.
  47. C
  48. C     ****************************************************************
  49. C
  50. C     Messages generated by this module :  None
  51. C
  52. C     ****************************************************************
  53. C
  54. C     Subroutines called directly : None
  55. C
  56. C     ****************************************************************
  57. C
  58. C     Files referenced :  None
  59. C
  60. C     ****************************************************************
  61. C
  62. C     Local variable definitions :
  63. C
  64. C     ****************************************************************
  65. C
  66. C     Commons referenced : KERPAR local common
  67. C
  68. C     ****************************************************************
  69. C
  70. C     (*$END.DOCUMENT*)
  71. C
  72. C     ****************************************************************
  73. C     *                                                              *
  74. C     *         D I M E N S I O N   S T A T E M E N T S              *
  75. C     *                                                              *
  76. C     ****************************************************************
  77. C
  78.       IMPLICIT INTEGER (A-Z)
  79.       INTEGER   LIN(1),      APAT(1)
  80. C
  81. C     ****************************************************************
  82. C     *                                                              *
  83. C     *         T Y P E   S T A T E M E N T S                        *
  84. C     *                                                              *
  85. C     ****************************************************************
  86. C
  87. C
  88. C     ****************************************************************
  89. C     *                                                              *
  90. C     *         C O M M O N   S T A T E M E N T S                    *
  91. C     *                                                              *
  92. C     ****************************************************************
  93. C
  94.       INCLUDE USL/KERPMC
  95. C
  96. C     ****************************************************************
  97. C     *                                                              *
  98. C     *         E Q U I V A L E N C E   S T A T E M E N T S          *
  99. C     *                                                              *
  100. C     ****************************************************************
  101. C
  102. C
  103. C     ****************************************************************
  104. C     *                                                              *
  105. C     *         D A T A   S T A T E M E N T S                        *
  106. C     *                                                              *
  107. C     ****************************************************************
  108. C
  109. C
  110. C     ****************************************************************
  111. C
  112. C     Code starts here :
  113. C
  114. C----->  Assume no match will be found.
  115. C
  116.       FINDLN = NO
  117.       T1=A1
  118. C
  119. C----->  Loop to find the next character in the command line
  120. C----->  that matches the first character in the pattern.
  121. C
  122.    10 CONTINUE
  123.       IF (LIN(T1) .EQ. APAT(1) .OR.
  124.      >    LIN(T1) .EQ.     EOS     ) GO TO 20
  125.       T1 = T1 + 1
  126.       GO TO 10
  127.    20 CONTINUE
  128. C
  129. C----->  If we found the end of the command line then
  130. C----->  no match was found, so return to caller.
  131. C
  132.       IF (LIN(T1) .EQ. EOS) RETURN
  133. C
  134. C----->  We found a possible match, so loop through and compare
  135. C----->  the next characters until a mismatch is found or the
  136. C----->  pattern ends.
  137. C
  138.       A1 = T1
  139.       T2 = 1
  140.       T3 = T1
  141.    30 CONTINUE
  142.       IF (APAT(T2) .NE. LIN(T1) .OR.
  143.      >    APAT(T2) .EQ.     EOS     ) GO TO 40
  144.       T1 = T1 + 1
  145.       T2 = T2 + 1
  146.       GO TO 30
  147.    40 CONTINUE
  148. C
  149. C----->  If the pattern is ended, then we have found a match,
  150. C----->  if not go back and continue looking.
  151. C
  152.       IF (APAT(T2) .EQ. EOS) GO TO 50
  153.       T1 = T3 + 1
  154.       GO TO 10
  155.    50 CONTINUE
  156.       Z1 = T1 - 1
  157.       FINDLN = YES
  158.       RETURN
  159.       END
  160.