/*-------------------------------------------------------------------*/
/* Program: SC001C */
/* Date Written: 08/13/07 */
/* Author: T. Winchester */
/* Description: Simple program to illustrate the use of the API */
/* called QCLSCAN. */
/* */
/*-------------------------------------------------------------------*/
PGM
/* Declare variables used by QCLSCAN */
DCL VAR(&INPUT) TYPE(*CHAR) LEN(99)
DCL VAR(&PATTERN) TYPE(*CHAR) LEN(5)
DCL VAR(&INPLEN) TYPE(*DEC) LEN(3 0) VALUE(99)
DCL VAR(&START) TYPE(*DEC) LEN(3 0) VALUE(1)
DCL VAR(&PATLEN) TYPE(*DEC) LEN(3 0) VALUE(5)
DCL VAR(&TRANSLAT) TYPE(*CHAR) LEN(1) VALUE('1')
DCL VAR(&TRIMBLKS) TYPE(*CHAR) LEN(1) VALUE('0')
DCL VAR(&WILDCARD) TYPE(*CHAR) LEN(1) VALUE(' ')
DCL VAR(&POSITION) TYPE(*DEC) LEN(3 0)
/* Work variable to contain results... */
DCL VAR(&OUTPUT) TYPE(*CHAR) LEN(20)
DCL VAR(&OUTLEN) TYPE(*DEC) LEN(3)
DCL VAR(&RESULT) TYPE(*CHAR) LEN(3)
/* Set the value of our input string...theoretically, this could */
/* come from anywhere (e.g. a screen, a return message, etc.) -AND- */
/* also specify the pattern we're looking for... */
CHGVAR VAR(&INPUT) VALUE('How now, brown cow')
CHGVAR VAR(&PATTERN) VALUE('BROWN')
/* Try to find our value within the string... */
CALL PGM(QCLSCAN) PARM(&INPUT +
&INPLEN +
&START +
&PATTERN +
&PATLEN +
&TRANSLAT +
&TRIMBLKS +
&WILDCARD +
&POSITION)
/* Convert our return value from decimal to character... */
CHGVAR VAR(&RESULT) VALUE(&POSITION)
/* Was the value found? */
IF COND( (&POSITION = 0) ) THEN(DO)
SNDUSRMSG MSG('The string ' *CAT &PATTERN *CAT ' was +
not found') MSGTYPE(*INFO) TOMSGQ(QSYSOPR)
GOTO CMDLBL(ENDJOB)
ENDDO
/* Just get 5 characters of the string... */
CHGVAR VAR(&OUTLEN) VALUE(&INPLEN - &POSITION)
/* Capture a few characters of the input string and store it... */
CHGVAR VAR(&OUTPUT) VALUE(%SST(&INPUT &POSITION +
&OUTLEN))
/* Finally, show what we found... */
SNDUSRMSG MSG('The pattern ' *CAT &PATTERN *CAT ' was +
located at position ' *CAT &RESULT) +
MSGTYPE(*INFO) TOMSGQ(QSYSOPR)
ENDJOB: ENDPGM
Terry
-----Original Message-----
From: midrange-l-bounces@xxxxxxxxxxxx
[mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of Alan Shore
Sent: Thursday, January 10, 2008 11:36 AM
To: Midrange Systems Technical Discussion
Subject: CLP question
Morning all
I have to make a change to a CLP program that reads a file.
I need to see if a particular field on that file contains a particular
string ANYWHERE within that field.
I know about %SST, but you need to know the starting position
and length.
Is there any other way of accomplishing this within CL?
Thanks in advance
Alan Shore
NBTY, Inc
(631) 244-2000 ext. 5019
AShore@xxxxxxxx
"If you're going through Hell, keep going" - Winston Churchill
--
This is the Midrange Systems Technical Discussion
(MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/midrange-l.
Confidentiality Notice:
The preceding e-mail message (including any attachments) contains information that may be confidential, protected by applicable legal privileges, or constitute non-public information. It is intended to be conveyed only to the designated recipient(s). If you are not an intended recipient of this message, please notify the sender by replying to this message and then delete it from your system. Use, dissemination, distribution or reproduction of this message by unintended recipients is
not authorized and may be unlawful.
As an Amazon Associate we earn from qualifying purchases.