Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Zeros falling off numbers
Message
 
À
04/07/2000 02:52:53
Garry Sankowsky
Zodiac Publications
Tolga, Australie
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00387952
Message ID:
00387968
Vues:
18
Sorry to say this, but if your program is 100% the same with what you posted, it's not a good coding habit. Your system will slow down long term.
Take a look on the revised program version below.
SELECT clones
SCAN
    STORE clone_num TO clnam
    STORE 0 TO totstrk, totstuck, netstuck, tracnt, mtotl
	
    ** WHILE is far faster than FOR clause statement
    SELECT bighouse
    SET ORDER TO clone_num
    =SEEK(clnam)
    SCAN WHILE clone_num = clnam
	totstruck = totstruck + bighouse.struck
	totstuck = totstuck + bighouse.numcut
	tracnt = tracnt + bighouse.trays
	mtot = mtot + mtotal
	If struck > 0
	    netstuck = netstuck + bighouse.numcut    
	Endif
    ENDSCAN
	
    strate = (totstrk/netstuck)*100

    SELECT clonestat
    SET ORDER TO clone_num
    =SEEK(clnam)
    CALCULATE SUM(losses) WHILE clone_num = clnam TO clout
    
    ** Take a look carefully on this code.
    ** Why is it that you always use FOR clause if this is already record to accomodate the total value?
    ** Doesn't it one record only per clone_num?
    ** However, clarify it further if my conclusion is wrong.
    SELECT clonetot
    LOCATE FOR clone_num = clnam
    IF FOUND()
	REPLACE num_sorted WITH totstrk-clout,;
    	        total      WITH (totstrk-clout)+mtot,;
        	numcut     WITH totstuck,;
            	no_plants  WITH totstrk,;
	        trays      WITH tracnt,;
    	        cut_house  WITH mtot
    	IF no_plants > 0
    		REPLACE strikerate WITH (no_plants/netstuck)*100 
    	ENDIF        
    ENDIF	     
    
    ** Go back to original table   
    SELECT clones
ENDSCAN	
HTH

Give me feedback.



>Code is as follows,
>
>*** now calculate number in stock of each clone
>SELECT clones
>GO TOP
>store clone_num to clnam
>select bighouse
>sum all struck for clone_num = clnam to totstrk && = total struck for this clone
>sum all numcut for clone_num = clnam to totstuck && = total put down for this clone
>SUM ALL NUMCUT FOR CLONE_NUM = CLNAM .AND. STRUCK > 0 TO NETSTUCK && = total put down for sorted nos
>sum all trays for clone_num = clnam to tracnt
>sum all mtotal for clone_num = clnam to mtot && total in mist house
>
>store (totstrk/netstuck)*100 to strate
>
>SELECT CLONESTAT
>sum all LOSSES for clone_num = clnam to clout
>select clonetot
>replace all num_sorted with totstrk-clout for clone_num = clnam && this is where it all goes wrong!
>replace all total with (totstrk-clout)+mtot for clone_num = clnam
>replace all numcut with totstuck for clone_num = clnam
>replace all no_plants with totstrk for clone_num = clnam
>replace all trays with tracnt for clone_num = clnam
>replace all cut_house with mtot for clone_num = clnam
>locate for clone_num = clnam
>if no_plants > 0
>
>replace strikerate with (no_plants/NETSTUCK)*100
>endif
>
>select clones
>skip
>enddo
>
>********
>If I do each line one at a time from the command window all is OK.
>
>Regards,
>Garry Sankowsky
JESS S. BANAGA
Project Leader - SDD division
...shifting from VFP to C#.Net

CHARISMA simply means: "Be more concerned about making others feel good about themselves than you are in making them feel good about you."
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform