View previous topic :: View next topic
|
Author |
Message |
nagamanjari
New User
Joined: 25 Apr 2008 Posts: 9 Location: hyderabad
|
|
|
|
Can anyone suggest a program which reads a file and process it. And finally writes into another flat file.
It will be very helpfull. |
|
Back to top |
|
|
hchinnam
New User
Joined: 18 Oct 2006 Posts: 73
|
|
|
|
One example below,
Code: |
/*REXX*/
SAY 'ITS WORKING'
DSN1= '''T.SATEESH.TEST'''
DSN2= '''T.SATEESH.OUT'''
SAY DSN1
"ALLOC DDN(NEWDD) DSN("DSN1") SHR REUSE"
"ALLOC DDN(OUTDD) DSN("DSN2") SHR REUSE"
"EXECIO * DISKR NEWDD (STEM NEWVAR."
SAY NEWVAR.0
I = 1
DO FOREVER
OUTVAR.I = SUBSTR(NEWVAR.I,1,20)
IF SUBSTR(NEWVAR.I,20,1) < 5
THEN NAME = 'DAVID'
ELSE NAME = 'WHITE'
OUTVAR.I = OUTVAR.I NAME
I = I + 1
IF I = NEWVAR.0 THEN
LEAVE
END
"EXECIO * DISKW OUTDD (STEM OUTVAR."
|
But i suggest you to go through rexx manuals to understand how each statement works.
If you know the basics and have a problem on working with them, then post your problem in full so that someone can help you. |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
Maybe I'm being picky ................................ but, the amended code will now close and free the input and output datasets to avoid problems of dataset / file allocations in case of reruns from an online terminal.
Code: |
/*REXX*/
SAY 'ITS WORKING'
DSN1= '''T.SATEESH.TEST'''
DSN2= '''T.SATEESH.OUT'''
SAY DSN1
"FREE FI(NEWDD,OUTDD)"
"ALLOC DDN(NEWDD) DSN("DSN1") SHR REUSE"
"ALLOC DDN(OUTDD) DSN("DSN2") SHR REUSE"
"EXECIO * DISKR NEWDD (STEM NEWVAR. FINIS"
SAY NEWVAR.0
I = 1
DO FOREVER
OUTVAR.I = SUBSTR(NEWVAR.I,1,20)
IF SUBSTR(NEWVAR.I,20,1) < 5
THEN NAME = 'DAVID'
ELSE NAME = 'WHITE'
OUTVAR.I = OUTVAR.I NAME
I = I + 1
IF I = NEWVAR.0 THEN
LEAVE
END
"EXECIO * DISKW OUTDD (STEM OUTVAR. FINIS"
"FREE FI(NEWDD,OUTDD)"
|
|
|
Back to top |
|
|
superk
Global Moderator
Joined: 26 Apr 2004 Posts: 4652 Location: Raleigh, NC, USA
|
|
|
|
A silly thing that reverses the text of each record:
Code: |
Do Forever
"EXECIO 1 DISKR indd"
If rc <> 0 Then Leave
Parse Pull myrec
outrec = ""
Do i = Length(Strip(myrec)) To 1 By -1
char = Substr(myrec,i,1)
outrec = outrec||char
End
Push outrec
"EXECIO 1 DISKW outdd"
End
"EXECIO 0 DISKR indd (FINIS"
"EXECIO 0 DISKW outdd (FINIS"
Exit 0
|
|
|
Back to top |
|
|
Pedro
Global Moderator
Joined: 01 Sep 2006 Posts: 2547 Location: Silicon Valley
|
|
|
|
I think the use of quotes is confusing. I use double quotes to delimit constants that include single quotes.
Code: |
DSN1= '''T.SATEESH.TEST''' |
Code: |
DSN1= "'T.SATEESH.TEST'" |
This way they look distinct from each other. |
|
Back to top |
|
|
|