進度條展示瞭如何製作進度條。 @abmayfield問題在“不回應”與“仍在思考”促使我重新審視這一點。 這是另一個例子,包括一個取消按鈕。
not cancelednot cancelednot cancelednot canceled沒有取消
Cancel button pressed.Cancel button pressed.Cancel button pressed.Cancel button pressed.取消按鈕被按下。
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>
在 JMP 15 和 16 之間進行測試,我注意到 16 是很多在此字符串連接工作負載上速度更快! 幹得好!
編輯:如果 JMP 運行的平台沒有自己的可取消進度條,並且運行時間很長,這不會有幫助。 技術支持是請求平台支持進度條的好地方。 如果沒有它,就沒有辦法(除非強行關閉 JMP)來停止它,直到它完成。
確實想要打包,謝謝!
在您的示例中, pb<
你還指出了我錯過的一些事情如何使用定義類:我認為我需要在定義類原型中顯式地佈置類成員,但是這:也可以創建它們。
Define Class("bubble",
//not needed: m_xpos = .;
_init_ = Method( {x}, <BR />//because using explicit this: ...
this:m_xpos = x;
謝謝@Craige_Hales ! 我碰巧需要進度條(或類似的東西)到我的一個腳本,所以我接受了它並對其進行了一些修改以滿足我的需要。 我把它變成了一個課程(我對 JMP 的課程和一般課程非常初學者)實踐因為我覺得它可以融入其中。 我還添加了一些可以用 Natural Docs 解析的文檔。
代碼:
查看更多...自然文檔看起來像這樣:
