|
Try using the following
WORKING STORAGE
01 PARM.
05 PARM-STRING PIC X(999).
05 PARM-STRLEN PIC S9(03) COMP-3.
05 PARM-STRPOS PIC S9(03) COMP-3.
05 PARM-PATTERN PIC X(999).
05 PARM-PATLEN PIC S9(03) COMP-3.
05 PARM-TRANS PIC X(01).
05 PARM-TRIM PIC X(01).
05 PARM-WILD PIC X(01).
05 PARM-RESULT PIC S9(03) COMP-3.
PROCEDURE DIVISION
MOVE 120 TO PARM-STRLEN -- length of string to
search
MOVE 1 TO PARM-STRPOS -- starting position
of search
MOVE SEARCH-PAT TO PARM-PATTERN -- pattern to search
MOVE 25 TO PARM-PATLEN -- length of pattern
MOVE '1' TO PARM-TRANS -- ??
MOVE '1' TO PARM-TRIM -- trim pattern
MOVE ' ' TO PARM-WILD. -- wildcard char
MOVE SEARCH-STG TO PARM-STRING -- char string to
search
MOVE 0 TO PARM-RESULT -- initialize result
CALL 'QCLSCAN' USING PARM-STRING
PARM-STRLEN
PARM-STRPOS
PARM-PATTERN
PARM-PATLEN
PARM-TRANS
PARM-TRIM
PARM-WILD
PARM-RESULT.
The PARM-RESULT will be zero if pattern not found, otherwise it will be the
start position of the first occurance of pattern found within string.
See http://publib.boulder.ibm.com/infocenter/iseries/v5r3/index.jsp?lang=en
search for QCLSCAN in upper-left "Seach" for details from IBM.
Hope this helps...:-)
-----Original Message-----
From: cobol400-l-bounces@xxxxxxxxxxxx
[mailto:cobol400-l-bounces@xxxxxxxxxxxx] On Behalf Of M.Kamaleshwar
Sent: Tuesday, November 08, 2005 8:10 AM
To: cobol400-l@xxxxxxxxxxxx
Subject: [COBOL400-L] Equivalent of SCAN (as in RPG) in COBOL/400
HI ,
Can anybody help me out with this - my reqmt. is to search for the
occurence of a string (more than 1 character) in a variable and if the
string occurs then get the position of occurence in the variable In RPG one
can use SCAN to know whether the string is found in the variable as well as
get starting position of the occurence. What is the equivalent keyword in
COBOL/400 . I believe INSPECT only says whether the string occurs or not -
it doesn't give the starting position of occurence of the string.
Please suggest.
Thanks
---------------------------------
Yahoo! FareChase - Search multiple travel sites in one click.
--
This is the COBOL Programming on the iSeries/AS400 (COBOL400-L) mailing list
To post a message email: COBOL400-L@xxxxxxxxxxxx To subscribe, unsubscribe,
or change list options,
visit: http://lists.midrange.com/mailman/listinfo/cobol400-l
or email: COBOL400-L-request@xxxxxxxxxxxx Before posting, please take a
moment to review the archives at http://archive.midrange.com/cobol400-l.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2025 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.