Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Recno() Order
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Miscellaneous
Thread ID:
00442673
Message ID:
00442713
Views:
9
>As I scan through a file I was thinking of showing a wait window that shows recno() of reccount(). I understand that this won't do me much good, unless I can scan the file in recno() order. Is there a way to do this?
>
>Thanks,
>Paul

Hi Paul,

Bellow is the tecnique I use. One additional note: if your table is ordered don't use just scan... endscan (it would be slower). Either use scan while!eof() endscan or do while!eof()... skip... enddo.
local lnSeconds, lnMinutes

local lnReccount, lnRecno, StartTime, prevonesc, prevescape, ;
      msgtail, lnCount, mnend, lcOrder, ;
      lnUpdateNumber, pcMapID, lcAPN, lnBadApn

* note clock reading for generating final timing statistics
StartTime = seconds()                         && # seconds since midnight

select BldMstr

lcOrder=order()
set order to 

lnRecno=recno() && Save  current record

* support user Escapes for interrupting the main loop
prevonesc = on('escape')                    && save previous Escape handler
prevescape = set('escape')                    && previous Escape enablement state
set escape on                                   && enableme escape handling
halt = .f.                                        && allow loop to run until this flag is toggled
on escape halt = .t.                         && force immediate termination if user escapes
store 0 to lnTally, lnCount, lnBadAPN

lnReccount=reccount()

do case
  case lnReccount<100 && Very rare case
    lnUpdateNumber=1
  case between(lnReccount,100,10000)
    lnUpdateNumber=100
  case lnReccount>10000
    lnUpdateNumber=val('1'+replicate('0',len(transform(lnReccount))-3))
endcase        

* assemble fixed portion of status bar message outside of loop, for speed
msgtail = "/" + transform(lnReccount) + ".  Wait or press Esc to cancel ..."
set message to
*--- instantiate thermometer bar class....
lotherm = newobject("thermometer", "wg","","Progress for APN calculating...",lnReccount)
lotherm.show()

scan  
     lnCount=lnCount+1

* check for user Escape
     if m.halt                                   && user escaped
          exit                                   && fall out of loop
     endif

** Update thermometr
     if mod(lnCount,lnUpdateNumber) = 0
          set message to 'Record # '+alltrim(str(lnCount))+m.msgtail
          lotherm.update(lnCount)
     endif
HTH
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform