home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
kermit.columbia.edu
/
kermit.columbia.edu.tar
/
kermit.columbia.edu
/
archives
/
modcomp.zip
/
findln.
< prev
next >
Wrap
Text File
|
1987-01-26
|
6KB
|
160 lines
INTEGER FUNCTION FINDLN (LIN,APAT,A1,Z1)
C
C ****************************************************************
C
C KERMIT for the MODCOMP MAXIV operating system
C
C Compliments of:
C
C SETPOINT, Inc.
C 10245 Brecksville Rd.
C Brecksville, Ohio 44141
C
C
C KERMIT is a copyrighted protocol of Columbia Univ. The authors
C of this version hereby grant permission to copy this software
C provided that it is not used for an explicitly commercial
C purpose and that proper credit be given. SETPOINT, Inc. makes
C no warranty whatsoever regarding the accuracy of this package
C and will assume no liability resulting from it's use.
C
C ****************************************************************
C
C Abstract: This function will try to find the pattern within
C a line. It alse returns the value of where the
C pattern begins and ends.
C
C MODIFICATION HISTORY
C
C BY DATE REASON PROGRAMS AFFECTED
C
C ****************************************************************
C
C Author: Bob Borgeson Version: A.0 Date: Aug-86
C
C Calling Parameters:
C
C R LIN - Array that holds the line to search
C R APAT - Array that holds the pattern to search for
C R/W A1 - Initially tells this routine where to start
C looking for a match. On return it tells the
C caller where the matched pattern begins.
C W Z1 - Tells the calling program where the matched
C pattern ends. EOS is not counted in the Z1
C value.
C W FINDLN - Function value, = YES, pattern was found,
C = NO, pattern was not found.
C
C ****************************************************************
C
C Messages generated by this module : None
C
C ****************************************************************
C
C Subroutines called directly : None
C
C ****************************************************************
C
C Files referenced : None
C
C ****************************************************************
C
C Local variable definitions :
C
C ****************************************************************
C
C Commons referenced : KERPAR local common
C
C ****************************************************************
C
C (*$END.DOCUMENT*)
C
C ****************************************************************
C * *
C * D I M E N S I O N S T A T E M E N T S *
C * *
C ****************************************************************
C
IMPLICIT INTEGER (A-Z)
INTEGER LIN(1), APAT(1)
C
C ****************************************************************
C * *
C * T Y P E S T A T E M E N T S *
C * *
C ****************************************************************
C
C
C ****************************************************************
C * *
C * C O M M O N S T A T E M E N T S *
C * *
C ****************************************************************
C
INCLUDE USL/KERPMC
C
C ****************************************************************
C * *
C * E Q U I V A L E N C E S T A T E M E N T S *
C * *
C ****************************************************************
C
C
C ****************************************************************
C * *
C * D A T A S T A T E M E N T S *
C * *
C ****************************************************************
C
C
C ****************************************************************
C
C Code starts here :
C
C-----> Assume no match will be found.
C
FINDLN = NO
T1=A1
C
C-----> Loop to find the next character in the command line
C-----> that matches the first character in the pattern.
C
10 CONTINUE
IF (LIN(T1) .EQ. APAT(1) .OR.
> LIN(T1) .EQ. EOS ) GO TO 20
T1 = T1 + 1
GO TO 10
20 CONTINUE
C
C-----> If we found the end of the command line then
C-----> no match was found, so return to caller.
C
IF (LIN(T1) .EQ. EOS) RETURN
C
C-----> We found a possible match, so loop through and compare
C-----> the next characters until a mismatch is found or the
C-----> pattern ends.
C
A1 = T1
T2 = 1
T3 = T1
30 CONTINUE
IF (APAT(T2) .NE. LIN(T1) .OR.
> APAT(T2) .EQ. EOS ) GO TO 40
T1 = T1 + 1
T2 = T2 + 1
GO TO 30
40 CONTINUE
C
C-----> If the pattern is ended, then we have found a match,
C-----> if not go back and continue looking.
C
IF (APAT(T2) .EQ. EOS) GO TO 50
T1 = T3 + 1
GO TO 10
50 CONTINUE
Z1 = T1 - 1
FINDLN = YES
RETURN
END