Fortschrittsanzeige zeigte, wie man einen Fortschrittsbalken erstellt. @abmayfield Frage rein „reagiert nicht“ vs. „denkt immer noch“ hat mich dazu veranlasst, noch einmal darüber nachzudenken. Hier ist eine weitere Einstellung, einschließlich einer Schaltfläche zum Abbrechen.
not cancelednot cancelednot cancelednot cancelednicht storniert
Cancel button pressed.Cancel button pressed.Cancel button pressed.Cancel button pressed.Abbrechen-Taste gedrückt.
progressBarWidth = 500;
progressUpdatesSeconds = 1 / 4; // 1/2 sec updates -> 1300ips, 1/30 -> 1000ips (1/4 compromise speed vs appearance)
cancel = 0; // clear the cancel flag
New Window( "Progressbar demo", //
V List Box( //
cats = Text Box( "" ), // output from the work function
t = Text Box( "", <<SETWRAP> ^workCalls/runSeconds^ ips" ) );
t << updatewindow; // this works without the wait
);
totalCats = 0;
dowork = Function( {},
x = "";
For( i = 1, i <= 1000, i += 1, x = x || "." );
totalCats += 1000;
cats << settext( Eval Insert( "total concatenations=^totalCats^" ) );
);
While( runSeconds < limitSeconds & !cancel, // change this to represent the work you are doing
// do some work, simulated by concatenating strings...
dowork();
// update the progressbar
workCalls += 1;
nowMicroSeconds = HP Time();
// how often does it need to update on the screen?
If( (nowMicroSeconds - recentUpdateMicroSeconds) / 1e6 > progressUpdatesSeconds,
// in this example I'm using a fixed time duration of "limitSeconds" to represent the
// amount of work to be done. And "runSeconds" to represent the amount of work done so far.
// Usually you'll have something other than time: number of rows in a table perhaps, or
// number of categories to make reports for. As long as you know how many total and how
// many completed, you can compute this fraction...
updateProgress( runSeconds / limitSeconds ); // change this to represent the fraction of work finished
recentUpdateMicroSeconds = nowMicroSeconds;
Wait( 0 ); // this wait is needed to let the cancel button work
);
runSeconds = (nowMicroSeconds - startMicroSeconds) / 1e6;
);
If( cancel, // test the cancel flag
Beep(); // audio flag
left << color( "dark red" ); // visual flag something is awry
right << color( "red" );
, //
updateProgress( 1.0 ); // people like to see the bar go to 100%
);
cancelButton << setbuttonname( "Close" ); // visual flag the button function is changed
cancelButton << setscript( (cancelButton << closewindow) ); // and what to do if the button is pressed
</SETWRAP>
Beim Testen zwischen JMP 15 und 16 ist mir aufgefallen, dass 16 ein ist viel schneller bei dieser String-Verkettungs-Arbeitslast! Gute Arbeit!
Bearbeiten: Wenn JMP eine Plattform ausführt, die über keinen eigenen abbrechbaren Fortschrittsbalken verfügt, und diese über einen längeren Zeitraum ausgeführt wird, wird dies nicht helfen. Der technische Support wäre ein guter Ort, um den Plattform-Support für einen Fortschrittsbalken anzufordern. Ohne sie gibt es keine Möglichkeit (außer JMP zwangsweise zu schließen), es zu stoppen, bis es fertig ist.
Es möchte verpackt werden, danke!
In Ihrem Beispiel ist pb<
Sie haben auch auf etwas hingewiesen, das ich übersehen habe So verwenden Sie „Klasse definieren“. : Ich dachte, ich müsste die Klassenmitglieder explizit im Definitionsklassenprototyp anordnen, aber Das: kann sie auch erstellen.
Define Class("bubble",
//not needed: m_xpos = .;
_init_ = Method( {x}, <BR />//because using explicit this: ...
this:m_xpos = x;
Danke @Craige_Hales ! Ich brauchte zufällig einen Fortschrittsbalken (oder etwas Ähnliches) für eines meiner Skripte, also habe ich diesen genommen und ihn ein wenig an meine Bedürfnisse angepasst. Ich habe daraus eine Klasse gemacht (ich bin sehr Anfänger mit den JMP-Klassen und Klassen im Allgemeinen) für üben und weil ich das Gefühl hatte, dass es in eines passen könnte. Ich habe auch einige Dokumentationen hinzugefügt, die mit Natural Docs analysiert werden können.
Code:
Mehr sehen...Natürliche Dokumente sehen in etwa so aus:
