Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

While loop confusion

Status
Not open for further replies.

arun10427

Programmer
Oct 24, 2009
29
0
0
US
Hi
I am accessing a dbf file with lots of records. This is the portion of code where I am having confusion about!
CODE

while ($i<=$rdb->last_record)
{
my @data = $rdb->get_record($i,"X", "Y"
if($data[2]<20)
{
$comment = "Good";
wdb->set_record($i,$data[1],$data[2],$comment);
}
if($data[2]>20)
{
#PLEASE HELP ME FILL THIS PART
}
This is what I have to do

--> If value of Y is less than 20
-> Write comments as good
-->If value of Y is 20 or greater
->Keep looking until X value is greater than 5
->Count number of records until X value 5 is reached--(*)
->If number of these consecutive records counted in (*) is greater than 10
-->write bad_not_fixed to comments
->If number of consecutive records counted in (*) is 10 or less
--> write fixed to comments
The main reason for my confusion is how do you first finish counting the records(10) and then go back and write? Please help me with this.
I wold really appreciate it.
Cheerz
 
Basically,

if i have 50 records, with X,Y and comments column(comments is empty column at start). My motive is based on the values of X and Y column I have to populate comments column.

If value of X is greater than 20
then I traverse the Y records till the value of Y reaches 5, If the number of Y records I had to traverse is greater than 10,I write
bad_not_fixed to the comments column corresponding to Y records traversed upto 5. If the number of Y records is less, I write fixed to comments for the Y records counted.


In short, count records till Y reaches value of 5, If counted records>10 "comments = bad_not_fixed " else "fixed"

Sorry about posting it again.
 
I guess you'll have to accumulate your Y records into an array until you know how many there are; then you can go back and update them according to your logic.

Annihilannic.
 
Yes. I've already told him as much in thread219-1590033...

Steve

[small]"Every program can be reduced by one instruction, and every program has at least one bug. Therefore, any program can be reduced to one instruction which doesn't work." (Object::perlDesignPatterns)[/small]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top