View previous topic :: View next topic
|
Author |
Message |
RBABU
New User
Joined: 23 Nov 2022 Posts: 5 Location: India
|
|
|
|
Hi,
Nice to see you all for assisting. I am new to REXX.
Need REXX program for the below requirement.
Read input file(len=999, rec count=100). from 1 to 670 data in alpha numeric.
check @position 671 for number of counts. If entries greater than 0 then proceed to extract data.
If count is 2 then extract data from 2 positions
if count is 3 then extract data from 3 positions
If count is 0 then just move spaces.
Input file in Hex format:
00000B8E4440BB44440000444
02004B240004A500000000000
Input file 1 record given sample data starting from position 671 (hex format)
pos 671 to 672 in hex, the decimal value is 2(count)
pos 675 to 679 in hex, the decimal value is 79397604
pos 682 to 686 in hex, the decimal value is 79344960
There are spaces between 2 values, just ignore.
Output file looks like:
79397604 79344960
Would be appreciated if you could help to provide the code asap.
Kindly get back to me in case I am not making you clear. Thank you |
|
Back to top |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3075 Location: NYC,USA
|
|
|
|
RBABU, please always start a new topic and use code tags when providing sample data or code. |
|
Back to top |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3075 Location: NYC,USA
|
|
|
|
Reply from Willy.
Quote: |
A few things to start with:
Var1 = Substr(input,671,lenght(input) /* take all data till end of file */
'input' should be 'input.i' to get the stem
you should not have 'length(input)' as default is to the end. And you are missing an end paranthesis, so you must have had an error message.
pos= pos(j3,j2)
I don't see you seting j3 or j2 anywhere.
in general don't use the name of a function, like 'pos' as a variable. while it works, it is confusing.
if substr(pos,j) you should have a 3rd parameter '1'.
outfile.data I don't see you define 'data' anywhere.
else nop is superfluous and a waste of a line
j=j+1 I don't see you using j anywhere
_________________
WJ |
|
|
Back to top |
|
|
sergeyken
Senior Member
Joined: 29 Apr 2008 Posts: 2119 Location: USA
|
|
|
|
After the latest clean-up of the topic it is now not possible to understand anything from the content left hereā¦ |
|
Back to top |
|
|
Rohit Umarjikar
Global Moderator
Joined: 21 Sep 2010 Posts: 3075 Location: NYC,USA
|
|
|
|
I would let TS explain again one time if still wants to peruse further but let us please stick to the problem and solution than sideways. |
|
Back to top |
|
|
Pedro
Global Moderator
Joined: 01 Sep 2006 Posts: 2585 Location: Silicon Valley
|
|
|
|
If I recall correctly, the poster was trying to do something too hard for a beginner. My suggestion is to start with a simple program then do incremental improvements as you get it to work. Use a smaller test data file, of shorter record length. Then write code to demonstrate that you can read and process all of the records. Add SAY statements to prove to yourself.
Then later switch to the longer record length, but with only a few data records (maybe up to 5 records). And be sure to you know which records have the desired data.
Then add the checks of data records that you are interested in.
Then switch to your actual data file.
Learn to use the TRACE command. |
|
Back to top |
|
|
RBABU
New User
Joined: 23 Nov 2022 Posts: 5 Location: India
|
|
|
|
Rohit Umarjikar wrote: |
RBABU, please always start a new topic and use code tags when providing sample data or code. |
Sure Rohit Sir. I will start new one. Many thanks |
|
Back to top |
|
|
|