Ask the Expert

CL source file searching for a specific library name

I am writing a program that reads through a CL source file searching for a specific library name (PANDPGM or PANDFIL) if found the hard coded library will be replaced by a variable (&pgmlib or &FILLIB) and some code will be inserted to retrieve these libraries from a message file. I am using RPGIV and attempting to use %scan %replace but am not having much success. Could you provide an example?


Here you go:

 
C                   EVAL      ScnPos = %SCAN('PANDPGM': SRCDTA)    
C                   If        (ScnPos > 0)                         
C                   EVAL      SRCDTA = %REPLACE('&PGMLIB': SRCDTA: 
C                               ScnPos: 7)                         
C                   End                                            
C                   EVAL      ScnPos = %SCAN('PANDFIL': SRCDTA)    
C                   If        (ScnPos > 0)                         
C                   EVAL      SRCDTA = %REPLACE('&FILLIB': SRCDTA: 
C                               ScnPos: 7)                         
C                   End     

This was first published in May 2001

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

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
Sort by: OldestNewest

Forgot Password?

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

Your password has been sent to: