LIKE command in cobol

5 pts.
Tags:
COBOL
LIKE statement
how to use LIKE command in cobol programming



Software/Hardware used:
software
ASKED: October 7, 2009  4:29 PM
UPDATED: October 8, 2009  7:31 PM

Answer Wiki

Thanks. We'll let you know when a new response is added.

Personally I use the Scan for String Pattern (QCLSCAN) API which is much more useful than the INSPECT stm.

Code:
Field
STRING <== The field to be scanned
STRLEN <== The length of the string to be scanned
STRPOS <== Starting position
PATTERN <== Value to scan
PATLEN <== Length of character(s) to scan
TRANSLATE <== No translation to upper char required
TRIM <== Blank characters trimmed
WILD <== No wildcard character
RESULT <== A value returned to your program

Call “QCLSCAN” Using STRING, STRLEN, …, RESULT.

If RESULT > 0 ==> PATTERN found and the result is the position of
the first character of the pattern in the string..

<ul>
Coding Examples</ul>

To create data item DEPTH with the same attributes as data item HEIGHT, you
simply write:
DEPTH <b>LIKE</b> HEIGHT

To create data item PROVINCE with the same attributes as data item STATE,
except one byte longer, you write:
PROVINCE <b>LIKE</b> STATE (+1)

Hi,

I am unaware of a LIKE command in COBOL. COBOL has a MOVE statement, an ADD statement, a WRITE statement, and many more. But I don’t think there is a LIKE statement.

Please update this with a more precise question.

Steve

———————————————————–

The LIKE clause for a Data Division data description entry has been available since at least V3 days (and probably earlier) for both OPM and ILE COBOL.

Bruce

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following