*--- instantiate thermometer bar class.... loTherm = newobject("thermometer", "wg.vcx","","MMR Calculation Progress for: "+m.lcOutTableFullName,m.lnTally) loTherm.show() local lcccTown, lnRank k=0 do while k<3 and not m.llHalt k=m.k+1 && Increment count for i=m.lnStart to m.lnEnd step m.lnStep && Two ranking (by Num and by Vol) select ('curAll'+transform(m.k)) set order to tag tag(m.i) descending && Reverse order NumAll, VolAll, NumPur, etc. lcccTown=ccode+town lnRank=0 scan for !m.llHalt lnCount=m.lnCount+1 ** Update status message if mod(m.lnCount,100) = 0 set message to 'Record # '+transform(m.lnCount)+m.lcMsgTail endif ** Update thermometer if mod(m.lnCount,m.lnUpdateNumber) = 0 loTherm.update(m.lnCount) endif scatter memvar && name loTemp lcSearchExpr=m.ccode + m.town if seek(m.lcSearchExpr, 'curSumAll'+transform(m.k), 'cctown') select ('curSumAll'+transform(m.k)) do case case m.i=1 && NumAll lcExt='All' lnTotal= YtdNumAll && for all lenders in this town if m.lnTotal>0 && Should be always >0 MksNumAll=round((m.YtdNumAll/m.lnTotal)*100,2) else MksNumAll=0 endif release MksNumPur, RankNumPur, MksNumRef, RankNumRef, ; MksVolPur, RankVolPur, MksVolRef, RankVolRef, ; MksVolAll, RankVolAll case m.i=2 && VolAll lcExt='All' lnTotal= YtdVolAll && for all lenders in this town if m.lnTotal>0 && Should be always >0 MksVolAll=round((m.YtdVolAll/m.lnTotal)*100,2) else MksVolAll=0 endif release MksNumPur, RankNumPur, MksNumRef, RankNumRef, ; MksVolPur, RankVolPur, MksVolRef, RankVolRef, ; MksNumAll, RankNumAll case m.i=3 && NumPur lcExt='Pur' lnTotal=YtdNumPur && for all lenders in this town if m.lnTotal>0 && Should be always >0 MksNumPur=round((m.YtdNumPur/m.lnTotal)*100,2) else MksNumPur=0 endif release MksNumAll, RankNumAll, MksNumRef, RankNumRef, ; MksVolAll, RankVolAll, MksVolRef, RankVolRef, ; MksVolPur, RankVolPur case m.i=4 && VolPur lcExt='Pur' lnTotal=YtdVolPur && for all lenders in this town if m.lnTotal>0 && Should be always >0 MksVolPur=round((m.YtdVolPur/m.lnTotal)*100,2) else MksVolPur=0 endif release MksNumAll, RankNumAll, MksNumRef, RankNumRef, ; MksVolAll, RankVolAll, MksVolRef, RankVolRef, ; MksNumPur, RankNumPur case m.i=5 && NumRef lcExt='Ref' lnTotal=YtdNumRef && for all lenders in this town if m.lnTotal>0 && Should be always >0 MksNumRef=round((m.YtdNumRef/m.lnTotal)*100,2) else MksNumRef=0 endif release MksNumAll, RankNumAll, MksNumPur, RankNumPur, ; MksVolAll, RankVolAll, MksVolPur, RankVolPur, ; MksVolRef, RankVolRef case m.i=6 && VolRef lcExt='Ref' lnTotal=YtdVolRef && for all lenders in this town if m.lnTotal>0 && Should be always >0 MksVolRef=round((m.YtdVolRef/m.lnTotal)*100,2) else MksVolRef=0 endif release MksNumAll, RankNumAll, MksNumPur, RankNumPur, ; MksVolAll, RankVolAll, MksVolPur, RankVolPur, ; MksNumRef, RankNumRef endcase endif if left(m.lender,4)='MISC' or m.lender='SELLER' ** Nothing else lnRank=m.lnRank+1 store m.lnRank to ('m.Rank'+iif(mod(m.i,2)=1,'Num','Vol')+ m.lcExt) endif if m.ccode+m.town<>m.lcccTown lcccTown= m.ccode+m.town if left(m.lender,4)='MISC' or m.lender='SELLER' lnRank=0 else lnRank=1 store m.lnRank to ('m.Rank'+iif(mod(i,2)=1,'Num','Vol')+m.lcExt) endif endif lcSearchExpr=m.lcSearchExpr+m.lender select OutTable if not indexseek(m.lcSearchExpr,.t.) && 'OutTable','ccttlndr') insert into OutTable from memvar else gather memvar && name loTemp fields ccode, town, Lender, LndrName, county, ; *!* city, State, ; *!* YtdNumAll, YtdVolAll, PtdNumAll, PtdVolAll, ; *!* YtdNumPur, YtdVolPur, PtdNumPur, PtdVolPur, ; *!* YtdNumRef, YtdVolRef, PtdNumRef, PtdVolRef, ; *!* &lcFieldsAdd endif endscan next * Finished with curAll use in select('curAll'+transform(m.k)) select ('curSumAll'+transform(m.k)) scan for !m.llHalt lnCount=m.lnCount+1 ** Update status message if mod(m.lnCount,100) = 0 set message to 'Record # '+transform(m.lnCount)+m.lcMsgTail endif ** Update thermometer if mod(m.lnCount,m.lnUpdateNumber) = 0 loTherm.update(m.lnCount) endif scatter memvar lcSearchExpr=m.ccode + m.town + m.lender select OutTable if not indexseek(m.lcSearchExpr,.t.) && 'OutTable','ccttlndr') insert into OutTable from memvar else gather memvar endif endscan use in select('curSumAll'+transform(m.k)) enddo>>Hi everybody,
>[snipped]
>>>local lcccTown, lnRank, lcFieldsAdd >set text to temp.prg >set text on >set textmerge delim to "[[,]]" && or so, just to make it readable here >\lparam cFile >for i=m.lnStart to m.lnEnd step m.lnStep > \select (cFile) > \set order to [[tag(m.i)]] desc > \lcccTown=ccode+town > \lnRank=0 > \scan for !m.llHalt > \ lnCount=m.lnCount+1 > \ scatter name loTemp > \ with loTemp > do case > case m.i=1 > \ lcExt='All' > \ lnTotal= && for all lenders in this town > \ if YtdNumAll>0 && Should be always >0 > \ .MksNumAll=round((.YtdNumAll/YtdNumAll)*100,2) > \ else > \ .MksNumAll=0 > \ endif > \ lcFieldsAdd='MksNumAll, RankNumAll' > \ if left(.lender,4)='MISC' or .lender='SELLER' >\** Nothing > \ else > \ lnRank=m.lnRank+1 > \ store m.lnRank to ('loTemp.Rank'+iif(mod(m.i,2)=1,'Num','Vol')+m.lcExt) > \ endif >* add the rest the same wayy > \ endwith > \ select OutTable > \ if not seek(m.lcSearchExpr,'OutTable','ccttlndr') >** We're now on the right record > \ insert into outtable ({key field here}) value (m.lcSearchExpr) > \ endif > \ gather name loTemp fields ccode, town, Lender, LndrName, county, ; > \ city, State, ; > \ YtdNumAll, YtdVolAll, PtdNumAll, PtdVolAll, ; > \ YtdNumPur, YtdVolPur, PtdNumPur, PtdVolPur, ; > \ YtdNumRef, YtdVolRef, PtdNumRef, PtdVolRef, ; > \ MksNumAll, RankNumAll > \ endscan > case m.i=2 >{etc etc, just repeat this for others) >endfor >set text off >set text to > >k=0 > >do while k<3 and not m.llHalt > k=m.k+1 && Increment count > do temp with ('curAll'+transform(m.k)) >enddo >>