Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SCAN FOR ... WHILE
Message
From
15/05/1999 00:10:01
 
 
To
14/05/1999 13:28:36
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00219112
Message ID:
00219299
Views:
19
My advice is to avoid using both WHILE and FOR for any command that accepts them. Only very few programmers know how to combine them correctly, so, the code becomes "unreadable" for many. So, the maintenance is more difficult and the chances for bugs increase.

Vlad

>I've been using this technique for a while. I thought that the SCAN FOR would start at the top of the file and act as a filter only looking at records that meet the condition and the WHILE would cause the loop to end as soon as its condition was false.
>
>This is just a bogus example to illustrate the point.
>
>
>
>lnInvoiceHdrId = Invoice.iInvoiceHdrId
>
>llTableUpdateOk = .T.
>
>SELECT InvoiceDtl
>SCAN FOR InvoiceDtl.iInvoiceHdrId = lnInvoiceHdrId WHILE ;
>         llTableUpdateOk
>     llTableUpdateOk = TABLEUPDATE( .F., .F., "InvoiceDtl" )
>
>ENDSCAN
>
>
>
>I thought that this would start at the top of the file and find all Invoice details that matched that Id and continue until it hits the end of the file or when the tableupdate fails.
>
>Similaray SCAN has an implicit WHILE NOT EOF() by itself.
>
>So does the SCAN WHILE without a FOR start at the top of the file or does it start from the current record positioning and move forward?
Previous
Reply
Map
View

Click here to load this message in the networking platform