Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Scan
Message
De
04/07/2003 03:55:54
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Re: Scan
Divers
Thread ID:
00806817
Message ID:
00806874
Vues:
17
>What's the difference between FOR and WHILE on SCAN
>
>WHILE does not work for me, but FOR works
>
>Is it the same ?

FOR - all records within the SCOPE matching the condition
If used alone automatically rewinds the pointer to top and operates on all records.

WHILE - carries the operation WHILE the condition is true

FOR and WHILE can coexist together and can be used with all scope supporting commands commands (scan, replace, browse, delete, locate etc)

Assuming using testdata files.
lcTempFile = Sys(2015)+'.tmp'
Set Textmerge to (lcTempFile) noshow
Set textmerge on

use customer
Locate for country='Germany'
\First record with Country = 'Germany' is rec#<<Recno()>> <<cust_id>>
skip && Move record pointer to show it rewinds
\Current record number <<Recno()>>
\Listing with scan for country = 'Germany'
\-----------------------------------------
scan for country = 'Germany'
\<<recno()>> <<cust_id>> <<country>>
EndScan
\-----------------------------------------

USE orders order tag cust_id
\
\=Seek('BERGS', 'orders', 'cust_id')
\scan while cust_id = 'BERGS' results
\---------------------------------

=Seek('BERGS', 'orders', 'cust_id')
scan while cust_id = 'BERGS'
 \Rec#<<Recno()>>: <<cust_id>> <<order_amt>>
endscan

\---------------------------------


\
\=Seek('BERGS', 'orders', 'cust_id')
\scan while cust_id = 'BERGS' for order_amt > 1000 results
\---------------------------------

=Seek('BERGS', 'orders', 'cust_id')
scan while cust_id = 'BERGS' for order_amt > 1000
 \Rec#<<Recno()>>: <<cust_id>> <<order_amt>>
endscan

\---------------------------------

\
\scan for order_amt > 1000 results
\---------------------------------
scan for order_amt > 1000
 \Rec#<<Recno()>>: <<cust_id>> <<order_amt>>
EndScan
\---------------------------------

Set Textmerge to
Set textmerge off
Modify Command (lcTempFile)
Erase (lcTempFile)
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform