Sunday, August 21, 2016

REXX: Left and Right Function is to beautify

Left and Right function...

Normally every programmer uses Left and Right function to strip the characters from left of a string or Right of a string.

For example:

String="hello"
Result=left(String,4)

This would REXX procedure would return Result as "hell".

REXX is normally used to automate routine manual tasks or generating codes. In order to keep the readability of the code in place, it is necessary we use the right functions to give us a standard alignment throughout the generated source.

The function Left and Right helps us a lot in the regard.

For example: Our task is to give a rating to every country in the world.

Country1="India"
Country2="USA"
Country3="Germany"

Rating1="1"
Rating2="2"
Rating3="3"

Statement1=left(Country1,20)!!left(Rating1,4)
Statement2=left(Country2,20)!!left(Rating2,4)
Statement3=left(Country3,20)!!left(Rating3,4)

This would result in a proper alignment.

Result would be...

India               1   
USA                 2   
Germany             3   

No comments:

Post a Comment

Featured Post

REXX Skeleton: Submitting jobs through Rexx

Submitting jobs through REXX and reading the spool through REXX gives us immense potential to automate many manual activities in mainframes....