Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Dennis Longfellow
  Where is Dennis Longfellow?
 Ballwin
 Missouri - United States
 Dennis Longfellow
 To: Ken Murphy
  Where is Ken Murphy?
 Springhill
 Canada
 Ken Murphy
 Tags
Subject: RE: For Exiting early
Thread ID: 75443 Message ID: 79076 # Views: 1 # Ratings: 0
Version: Visual FoxPro 6 Category: General VFP Topics
Date: Wednesday, October 12, 2005 5:14:19 PM         
   


Ken,

> As cString increases in size with the addition of spaces, what happens to LEN(cString) in the FOR? It doesn't change! I don't know if this is by design or if this is a bug. I ran into this myself a while ago. One would think that each time it loops through the "FOR" statement it should evaluate LEN(cString) but it doesn't. I think that VFP first evaluates LEN(cString) and stores this value to a local variable. It then exits when i > this local variable. In a similar situation, I ended up using a DO WHILE !llDone construct.
>
> Perhaps we could have one of our resident VIP's check with VFP on this. If it is by design, so be it, but if it is a bug, lets get it fixed.
>

This is by design as far as I can tell. The following note was copied from the VFP6 help for the FOR ... ENDFOR structure;

Note The values of nInitialValue, nFinalValue, and nIncrement are only read initially. However, changing the value of the counter MemVarName inside the loop affects the number of times the loop is executed.

I think this is fairly common for the definite iteration structure of computer languages where definite iteration is a defined number of passes through a loop. I am fairly certain that this is the way it worked in Pascal and BASIC. I took a Compiler Design Theory class when I was getting my Computer Science degree and we had to design a simple BASIC compiler. I know that my FOR ... NEXT loop would have worked this way. I got an A on the project, so I assume that I got it right.

Best regards,

Dennis Longfellow

ENTIRE THREAD

For Exiting early Posted by Nathan Davies @ 8/24/2005 5:13:30 AM
RE: For Exiting early Posted by Barbara Peisch @ 8/24/2005 6:58:11 AM
RE: For Exiting early Posted by Nathan Davies @ 8/24/2005 10:37:08 AM
RE: For Exiting early Posted by Boudewijn Lutgerink @ 8/25/2005 11:18:06 AM
RE: For Exiting early Posted by dan delpuerto @ 10/12/2005 3:33:11 PM
RE: For Exiting early Posted by Nathan Davies @ 10/12/2005 6:02:01 PM
RE: For Exiting early Posted by dan delpuerto @ 10/13/2005 11:56:36 PM
RE: For Exiting early Posted by Ken Murphy @ 10/12/2005 4:08:05 PM
RE: For Exiting early Posted by Dennis Longfellow @ 10/12/2005 5:14:19 PM