Help needed



IBM's Command List programming language & Restructured Extended Executor

Help needed

Postby naren123 » Sat Dec 22, 2012 1:39 pm

I am trying to develop a rexx code which will give the age of the person when i enter his/her name.

The flat file will be as follows:

david 20
anjan 23
hari 22
so on.....

the age starts at, say, 10th column.

When i enter a name, i want the REXX code to do the following :
1. Refer the PS file.
2. Search for the name in the flat file.
3. If found, then give only his/her age as the output.

i am confident of the 1st and 3rd. can anyone help me with the 2nd one?
naren123
 
Posts: 1
Joined: Sat Dec 22, 2012 1:14 pm
Has thanked: 0 time
Been thanked: 0 time

Re: Help needed

 

Re: Help needed

Postby enrico-sorichetti » Sat Dec 22, 2012 2:08 pm

when posting, good manners dictate to use an intelligent title...
it is obvious that You are asking for help, otherwise You would not have posted.

post what You have done ...

meditate on how to ...
extract/process the arguments
read the records into a stem
loop over the stem
extract part of a string using SUBSTR / WORD
compare <things>
...
...
...

to speed up the rexx learning process it would be a good thing to install on Your PC (*)
the current version of ooRexx from
http://sourceforge.net/projects/oorexx/

apart some I/O differences ( EXECIO is anyway available)
all the REXX facilities can be exercised without the hassle of a MF connection available

(*) YOUR OWN PC, NOT THE WORK ONE.
installing unauthorized software on Your employer PC can be cause for lawful termination
cheers
enrico
When I tell somebody to RTFM or STFW I usually have the page open in another tab/window of my browser,
so that I am sure that the information requested can be reached with a very small effort
enrico-sorichetti
Global moderator
 
Posts: 2643
Joined: Fri Apr 18, 2008 11:25 pm
Has thanked: 0 time
Been thanked: 130 times

Re: Help needed

Postby c62ap90 » Thu Dec 27, 2012 3:45 am

Something like this should do it with some minor changes...
/* REXX */
/********************************************************************/
/*** AUTHOR:  XXX                                                 ***/
/*** CREATED: 12/2012                                             ***/
/*** DESC:    -BROWSE TO GET AGE BY ENTERING NAME                 ***/
/*** NOTES:   -ON TSO/COMMAND LINE DO...TSO NAMEAGE < NAME >      ***/
/***                               IE...TSO NAMEAGE DAVID         ***/
/***                                    TSO NAMEAGE ANJAN         ***/
/*** CLIST:   XXXXXXXX.XXXXXXXX.CLIST(NAMEAGE)                    ***/
/*** PANEL:   NONE                                                ***/
/***  HELP:   NONE                                                ***/
/********************************************************************/
   PARSE UPPER ARG P_ARG
   P_ARG = STRIP(P_ARG)
   IF LENGTH(P_ARG) = 0 THEN DO
      SAY "==> OOPS: YOU MUST SUPPLY SEARCHABLE ARGUMENT < NAME >"
      EXIT
   END
   S_DSN = 'DATASET.NAME.HERE'
   "ALLOC F(NAMEAGE) DA('"S_DSN"') SHR REUSE"
   "EXECIO * DISKR NAMEAGE (FINIS STEM NAMEAGE."
   IF RC <> 0 THEN DO
      SAY "==> ERROR: READING "S_DSN", RC="RC
      EXIT
   END
   "FREE F(NAMEAGE)"
   B_FND = 0
   SP1 = " "
   CLRSCRN
   SAY "--NAME-- AGE   "
   DO I=1 TO NAMEAGE.0
      IF POS(P_ARG, NAMEAGE.I) > 0 THEN DO
         B_FND = 1
         PARSE VAR NAMEAGE.I 1 C1 15
         SAY C1
      END
   END
   IF B_FND = 0 THEN
      SAY " "P_ARG" NOT FOUND IN "S_DSN
   RETURN


Test Data Example:
----+----1----+----2-
*********************
DAVID    20         
AHJAN    23         
HARI     22         
NAREN123 23         

Change "DATASET.NAME.HERE' to your dataset.
I just noticed I have Name and Age; you can take "Name" out of 'SAY', and "1 C1 15" to "10 C1 15"

Example Execution:
tso nameage david
--NAME-- AGE 
DAVID    20   
***

Just play with it to get it exactly the way you want it.
c62ap90
 
Posts: 125
Joined: Thu Oct 11, 2012 10:24 pm
Has thanked: 1 time
Been thanked: 6 times


Return to CLIST & REXX

 


  • Related topics
    Replies
    Views
    Last post