Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Scan endscan break
Message
De
17/12/2007 16:54:29
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Divers
Thread ID:
01276291
Message ID:
01276341
Vues:
26
well... the 'goto' is not a proper command on structable programing.. But, how this one is a matter of logic.. The better decision up to you.. You're getting the view of all task..

The use of variable 'm.state' could be dangerous.. If you insert a command 'SCATTER' in other situations in a futrure..

the prefix 'lc' is a nice standard for your variables names.. 'l' of local and 'c' of character type.. So lcState works better for you..

>>>
>>>for each customer where customer.country='USA'
>>>    break by customer.state no-lock:
>>>
>>>    if first-of(customer.state) then do:
>>>        /* do something with first record */
>>>    end.
>>>
>>>    /* do something with records */
>>>
>>>    if last-of(customer.state) then do:
>>>        /* do something with last record  */
>>>    end.
>>>
>>>end.
>>>
>>>
>>>Scan endscan sort of does this but I cannot break. Can VFP do something like this?
>>
>>Not sure what the break does but here's my guess using dinosaur type code
>>
>>m.state = ''
>>m.llFirstGroup = .T.
>>
>>SCAN FOR customer.country = 'USA'
>>    lnCurRecno = RECNO()
>>    IF m.state <> customer.state
>>        IF NOT llFirstGroup
>>            GOTO lnLastRecno
>>            /* do something with last record */
>>            GOTO lnCurRecno
>>        ELSE
>>           llFirstGroup = .F.
>>        ENDIF
>>
>>      /* do the code for the first record */
>>       m.state = customer.state
>>    ENDIF
>>
>>    /* do the code for each record -- will include first record */
>>    lnLastRecno = RECNO()
>>ENDSCAN
>>
>>GOTO lnLastRecno
>>/* do something with last record */
>>
>>If you use SET FILTER rather than SCAN FOR you could use SKIPs rather than saving all the record numbers.
>>
>>Not sure how much this helped but hope it was something
>
>I think this is the right way to do it. Thanks!
"Now to him who is able to do immeasurably more than all we ask or imagine, according to his power that is at work within us, Ephesians 3:20
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform