Tags

, , , ,

REXX – INDEX, POS, SUBSTR, COMPARE

Using REXX code, I want to find if a particular word is present in the provided input string. Which of the below functions will help in meeting the requirement.

EX: Word to be found: REXX

Input String: This question is based on REXX

A) INDEX

B) POS

C) SUBSTR

D) COMPARE

Explanation for all the options is provided below.

A) INDEX: Returns the character position of the first character of a specified string found in the input string, otherwise 0.

PosNum = INDEX(StringToLookIn , StringtobeFound )

PosNum = INDEX(‘This question is based on REXX’, ‘REXX’ )

B) POS: Returns the character position of one string in another.

PosNum = POS(StringtobeFound, StringToLookIn)

PosNum = POS(‘REXX’,’This question is based on REXX’)

C) SUBSTR: Returns a portion of the input string beginning at a specified character position

Sub-string=SUBSTR(String,Start,Length)

So we can run a loop on the input string, and search for the word REXX in it.

D) COMPARE: Returns 0 if the two input strings are identical. Returns the position of the first character that does not match

Ex: COMPARE(‘ABC’,’ABC’) = 0

COMPARE(‘ABCD’,’ABC’) = 4

Here you can split the string into different words, and look into each word with the word

“REXX” that needs to be found using COMPARE function.

So all the options mentioned above can be used for the requirement.

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

In United States, If you would like to Earn Free Stocks, Credit card Points and Bank account Bonuses, Please visit My Finance Blog

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

You may also like to look at:

Important SQL CODES and ABEND CODES
SORT JOIN – TO JOIN TWO FILES BASED ON A KEY
KNOW YOUR MAINFRAME
REXX – INITIAL SETUP
EASYTRIEVE – A023 ABEND
EASYTRIEVE – SORT and FILE COMPARISION
EASYTRIEVE – Special-name Report Procedures
EASYTRIEVE – REPORT STAEMENT
EASYTRIEVE – Sample Program – Table And Search
EASYTRIEVE – Sample Program – Display Totals and Summary
EASYTRIEVE – Sample Program – Display Employee Data
CA-Easytrieve/Plus – Basics
REXX TOOL # 02 – FSAVE – Save member opened in VIEW mode
REXX TOOL # 01 – O – Open Any Mainframe Element from any ISPF Screen
REXX – INDEX, POS, SUBSTR, COMPARE
REXX – READ THE DSN PROVIDED AS DD IN JCL
REXX – SEND MULTIPLE ARGUMENTS THROUGH JCL
REXX – HOW TO COMPILE YOUR REXX EXEC
REXX – CHANGE UPPER TO LOWER CASE
REXX – GET LAST 4 DAYS FROM GIVEN DATE
REXX – PANEL Definition
REXX – READ, CREATE AND WRITE DATA TO A DATASET
REXX TOOL TO SUBSTITUTE SYMBOLICS IN A PROC
Advertisement