进度条展示了如何制作进度条。 @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 解析的文档。
代码:
查看更多...自然文档看起来像这样:
