Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Breaking Do While?
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00538059
Message ID:
00538662
Vues:
11
This message has been marked as the solution to the initial question of the thread.
>I didn´t think about it. It´s a good idea. Thanks Nadya!

Here is a technique I usually use for interrupting by ESC:
lnRecno=recno() && Save  current record in BldMstr
* 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                                   && 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
select BldMstr
set order to
if vartype(m.tnReccount)='N'
     lnReccount=m.tnReccount
else
     lnReccount=reccount()
endif
set message to 'Zipping BldMstr table with '+transform(m.lnReccount)+' records'
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
msgTail = "/" + transform(m.lnReccount) + ".  Wait or press Esc to cancel ..."

*--- instantiate thermometer bar class....
loTherm = newobject("thermometer", "wg.vcx","","Zipping Progress for: "+m.tcFileName,m.lnReccount)
loTherm.show()
lcRegion = " "

scan  for !m.llHalt && AND stnum > 0 AND UPPER(street)<> "ZZZ" && Should have indexes on SZipped, StNum, upper(street)
     lnCount=m.lnCount+1
** Update status message
     if mod(m.lnCount,100) = 0
          set message to 'Record # '+transform(m.lnCount)+m.msgTail
     endif
** Update thermometer
     if mod(m.lnCount,m.lnUpdateNumber) = 0
          loTherm.update(m.lnCount)
     endif
As you can see, on ESC I set variable Halt to be true. I do while !Halt

Sometimes I use some variations of this idea, so I call either form method or program, which allows me to ask user: "Are you sure, you want to stop?"
If it's not broken, fix it until it is.


My Blog
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform