Apple Newton Utilities Guide de l'utilisateur Page 633

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 942
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 632
CHAPTER 17
Additional System Services
Using Additional System Services 17-17
performing the myFunc function, pass it as the value of the workFunc parameter to
the
DoProgress function, as illustrated in the following code fragment:
// options and data are accessible from workFunc because
// the workFunc "closes over" this context
myOpts := { wFnData:"Confabulating",
closebox:nil,
icon: kMyIcon,
statusText: kAppName,
gauge: 10,
titleText:"One moment, please."};
workFunc := func (theContextView)
begin
for x := 1 to 10 do
begin
myOpts.titleText:= :SomeWork(myOpts.wFnData);
myOpts.gauge := x * 10;
try
theContextView:SetStatus('vGauge,myOpts);
// handle any exceptions you anticipate
onexception |evt.ex.foo| do
// handle & possibly rethrow if it's fatal
onexception |evt.ex.bar| do
// handle & possibly rethrow if it's fatal
onexception |evt.ex| do
// either an unexpected exception has been
// thrown or the user has canceled our
// operation. Perform any cleanup
// necessary, and be sure to rethrow..
ReThrow();
end; // for loop
end; // workFunc
progress := DoProgress('vGauge, myOpts, workFunc);
if progress = 'cancelled then
// this is another place to clean up after being
// cancelled
The workFunc function’s argument, theContextView, is the status slip that
contains the gauge. A reference to this view is passed to your work function so that
you can send it
SetStatus messages. Note that workFunc is structured in a way
that permits it to call the progress slip’s
SetStatus method at regular intervals,
passing values used to update the progress slip’s gauge and message string.
Vue de la page 632
1 2 ... 628 629 630 631 632 633 634 635 636 637 638 ... 941 942

Commentaires sur ces manuels

Pas de commentaire