View previous topic :: View next topic
|
Author |
Message |
praveenmaga
New User
Joined: 27 Jun 2009 Posts: 6 Location: Bangalore
|
|
|
|
Is there any command to write values to a particuler position in a VB file? |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Suggest you invest some more keystrokes and more completely describe your requirement. . .
Show what the input looks like and how you want the output to be written.
Mention the lrecl and recfm of the files. |
|
Back to top |
|
|
sathyaraj
New User
Joined: 28 Sep 2007 Posts: 71 Location: India.
|
|
|
|
There is no need to differentiate VB file from FB in your program. Rexx places the value in the position that you give. This position is what you see in the file by giving cols.
You can use either Insert or Overlay function to place your string in the desired position in your file.
Say if you want to insert a string 'AA' in the fifth column(This is what I assume you meant by a 'particular position')
Code: |
"EXECIO * DISKR INPUT (STEM INP. FINIS"
INP.1 = OVERLAY('AA',INP.1,5)
"EXECIO * DISKW INPUT (STEM INP. FINIS"
|
The above code will read the file and place 'AA' in the fifth column in the first record.
VB makes difference only when you catalog a dataset using Rexx. |
|
Back to top |
|
|
expat
Global Moderator
Joined: 14 Mar 2007 Posts: 8797 Location: Welsh Wales
|
|
|
|
sathyaraj wrote: |
VB makes difference only when you catalog a dataset using Rexx. |
Can you explain this, as I have never come across any differences in 20+ years of using REXX |
|
Back to top |
|
|
sathyaraj
New User
Joined: 28 Sep 2007 Posts: 71 Location: India.
|
|
|
|
I meant the record format (FB, VB) that we use while creating a new PS file using TSO command Allocate.
Plz correct me if I am wrong. |
|
Back to top |
|
|
prino
Senior Member
Joined: 07 Feb 2009 Posts: 1306 Location: Vilnius, Lithuania
|
|
|
|
sathyaraj wrote: |
I meant the record format (FB, VB) that we use while creating a new PS file using TSO command Allocate.
Plz correct me if I am wrong. |
And saying that grass is green is just as useful. |
|
Back to top |
|
|
sathyaraj
New User
Joined: 28 Sep 2007 Posts: 71 Location: India.
|
|
|
|
Quote: |
And saying that grass is green is just as useful.
|
Giving an additinal info doesnt gonna cause any harm. Thought it might be usefull to someone who is an alien to REXX. |
|
Back to top |
|
|
praveenmaga
New User
Joined: 27 Jun 2009 Posts: 6 Location: Bangalore
|
|
|
|
thnx.
Sorry i might have missed this infn in my post.
I don't want to add hard coded values to output file.
it should be like this--
read a input file and take the values from colm 2 to 3
and write to the first record in colm 8 to 10 in the output file. |
|
Back to top |
|
|
praveenmaga
New User
Joined: 27 Jun 2009 Posts: 6 Location: Bangalore
|
|
|
|
'EXECIO * DISKR HI (STEM LINES. FINIS'
DO I = 1 TO LINES.0
LINES.I = OVERLAY(LINES.I,2341)
'EXECIO * DISKW HI1 (STEM LINES. FINIS'
END
this is my code..
when i try this...its adding values to the first colums only in output file.
it should read first record and take the value from colm 2 to 3 and write to first record to a colm 7-8...so on, |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
To repeat:
Quote: |
Show what the input looks like and how you want the output to be written. |
It you had done as requested, you would have saved a day. . . |
|
Back to top |
|
|
sathyaraj
New User
Joined: 28 Sep 2007 Posts: 71 Location: India.
|
|
|
|
Hope this works..
Code: |
'EXECIO * DISKR HI (STEM LINES. FINIS'
'EXECIO * DISKR HI1 (STEM LINES1. FINIS'
DO I = 1 TO LINES.0
INP = SUBSTR(LINES.I,2,2)
LINES1.I = OVERLAY(INP,LINES.I,7)
END
'EXECIO * DISKW HI1 (STEM LINES1. FINIS'
|
Assuming your input and output file has different data.. you just want to take field in position 2-3 in input and overlay it in position 7-8 in output and that you have equal number of input and output records. |
|
Back to top |
|
|
praveenmaga
New User
Joined: 27 Jun 2009 Posts: 6 Location: Bangalore
|
|
|
|
Code: |
/* REXX */
...
'EXECIO * DISKR HI (STEM LINES. FINIS'
DO I = 1 TO LINES.0
N = SUBSTR(LINES.I,1,5)
SAY N
LINES.I = OVERLAY(N,LINES.I,2341)
END
'EXECIO * DISKW HI1 (STEM LINES. FINIS'
EXIT
|
I ran with this code now as you said... its overlaying at 2341 colm..also its overlaying in the starting colm 1. please advice. |
|
Back to top |
|
|
sathyaraj
New User
Joined: 28 Sep 2007 Posts: 71 Location: India.
|
|
|
|
oh man....
It is not overlaying in the column one. you are taking fielnd in position 1-5 and placing in 2341.
so the field will be in 2341 and it will be in column 1 as it is its actual position...
That is the reason I have used different stem in my previous example for input and output. If your output data is different read it into a stem before overlapping.. and overlap the output stem with your substring in the desired position.
Hope this helps. |
|
Back to top |
|
|
|