View previous topic :: View next topic
|
Author |
Message |
psriv20 Currently Banned New User
Joined: 25 May 2009 Posts: 19 Location: Pune
|
|
|
|
Hi All,
Please help me for following case.
Qus: I have one file have 6 records as follow
File1:
A
A
A
B
C
C
I need to create output file as follow.
Output File.
A 3
B 1
C 2
Thanks, |
|
Back to top |
|
|
Phrzby Phil
Senior Member
Joined: 31 Oct 2006 Posts: 1042 Location: Richmond, Virginia
|
|
|
|
Since you listed this in the COBOL section, I presume you want someone to help you write a COBOL program to increment counters and write the results to a file.
Didn't you do something like this in your first programmig course, regardless of what language you used? |
|
Back to top |
|
|
PeterHolland
Global Moderator
Joined: 27 Oct 2009 Posts: 2481 Location: Netherlands, Amstelveen
|
|
|
|
Phrzby Phil wrote: |
Since you listed this in the COBOL section, I presume you want someone to help you write a COBOL program to increment counters and write the results to a file.
Didn't you do something like this in your first programmig course, regardless of what language you used? |
Maybe the TS can start a new topic in the Job Vacancies (with the other 10
he put there) to find someone with experience enough to solve his problem. |
|
Back to top |
|
|
Robert Sample
Global Moderator
Joined: 06 Jun 2008 Posts: 8696 Location: Dubuque, Iowa, USA
|
|
|
|
Someone who has been a member of this forum for 2 and 1/2 years certainly should NOT be asking this type of question. Definitely a candidate for the Beginners and Students Forum |
|
Back to top |
|
|
Jose Mateo
Active User
Joined: 29 Oct 2010 Posts: 121 Location: Puerto Rico
|
|
|
|
Good day to all!
This has to be a school assignment but who gets the grade for helping you out. Well it goes something like this;
read file at end eof=yes
save char-field
perform until eof=yes
if char-field equal saved-char
increment counter by 1
else
write saved-char with counter
reset counter
save char-field
end-if
read file at end eof=yes
end-perform |
|
Back to top |
|
|
psriv20 Currently Banned New User
Joined: 25 May 2009 Posts: 19 Location: Pune
|
|
|
|
Thanks for reply ...
I did but some how my count always come one less than the actual ...
Now i got the issue.... |
|
Back to top |
|
|
Jose Mateo
Active User
Joined: 29 Oct 2010 Posts: 121 Location: Puerto Rico
|
|
|
|
oops!
On my logic above, define counter with a value of zero and on the reset counter it should be equal to 1 to count the record that cause the unequal condition. |
|
Back to top |
|
|
Jose Mateo
Active User
Joined: 29 Oct 2010 Posts: 121 Location: Puerto Rico
|
|
|
|
oops again!
I just want to add one last thing, After the end-perform do a last write of the saved-char with counter. |
|
Back to top |
|
|
Phrzby Phil
Senior Member
Joined: 31 Oct 2006 Posts: 1042 Location: Richmond, Virginia
|
|
|
|
So just curious Jose, while more senior and presumably more experienced forum members have implied to psriv20 that he should be able to write this program, and that asking members to write a simple program for him is inappropriate, you have nonetheless done so, yet did not even test your proposed code, even after the first time you realized an error.
How does this help psriv20?
Sure, he may get a working program with little effort, but how about the next time he needs a simple program - he'll have to ask again.
Where's his growth? |
|
Back to top |
|
|
Jose Mateo
Active User
Joined: 29 Oct 2010 Posts: 121 Location: Puerto Rico
|
|
|
|
I understand your point, Phil, And I didn't see his previous post on the forum. I was just thinking that he's a student by his question and he needed a little bit of help, of course he needs to code is program. |
|
Back to top |
|
|
|