Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Error handler (urgent)
Message
 
 
To
22/05/2001 02:46:58
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00509776
Message ID:
00509847
Views:
26
>my function is in do while loop and that loop is quit big. if i press ESC button that it show error and i am thrown out of the application . how to catch that error and instead of throughing out of APPLICATION it should throught out of the screen. help
>
>thanks

Mohammed,

This is the tecnique I use for interrupting scan loop (same for do while loop):
* note clock reading for generating final timing statistics
lnStartTime = seconds()                         && # seconds since midnight
select BldMstr
lcOrder=order()
set order to
lnRecno=recno() && Save  current record
* support user Escapes for interrupting the main loop
lcPrevOnEsc = on('escape')                    && save previous Escape handler
lcPrevEscape = set('escape')               && previous Escape enablement state
set escape on                                   && enable escape handling
llHalt = .f.                                   && allow loop to run until this flag is toggled
on escape llHalt = .t.                         && force immediate termination if user escapes
store 0 to lnTally, lnCount, lnBadApn, lnSuspect
lnReccount=reccount()
lnThreshold=int(m.lnReccount/10) && 10%
do case
case m.lnReccount<100 && Very rare case
     lnUpdateNumber=1
case between(m.lnReccount,100,100000)
     lnUpdateNumber=100
case m.lnReccount>100000
     lnUpdateNumber=val('1'+replicate('0',len(transform(m.lnReccount))-3))
endcase

* assemble fixed portion of status bar message outside of loop, for speed
lcMsgTail = "/" + transform(m.lnReccount) + ".  Wait or press Esc to cancel ..."
set message to ""
*--- instantiate thermometer bar class....
loTherm = newobject("thermometer", "wg","","Progress for APN calculating...", m.lnReccount)
loTherm.show()
scan
     lnCount=m.lnCount+1
* check for user Escape
     if m.llHalt                                   && user escaped
          exit                                   && fall out of loop
     endif
** Update thermometer
     if mod(m.lnCount, m.lnUpdateNumber) = 0
          set message to 'Record # '+alltrim(str(m.lnCount))+m.lcMsgTail
          loTherm.update(m.lnCount)
     endif
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform