Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Scan endscan break
Message
De
17/12/2007 17:12:21
 
 
À
17/12/2007 17:02:54
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:
01276348
Vues:
29
>>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..
>
>Your assertion that "GO TO..." is not "a proper command on structable programing" is incorrect.
>
>A "GO TO" that redirects code to another place for execution is what is unacceptable in structured programming.
>
>VFP's "GO TO" simply moves the record pointer, which is perfectly acceptable in structured programming. Just as the use of EXIT is fine in sturctured programming.
>
well.. it really depends.. I'm talking about clarity/intelligibility.. in a past goto represent leak of clarity on the logic as others stuffs for a programing team.. This is what I meant.. This is what represent a VFP's procedure full of goto 5, goto 4978, skip + 10, skip -10, etc... Only the author will deal fine with that one..


>
>
>>
>>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