回复:如何编写一个 JSL 脚本来调用和运行其他脚本而不打开脚本窗口但只显示一个取消按钮?这应该做你所要求的。 我还没有验证取消按钮是否有效,因为 JMP 非常快速地运行了我计算机上文件夹中的所有脚本。
/*JMP STATISTICAL DISCOVERY LLC (“JMP”) PERMITS THE USE OF THIS COMPUTER SOFTWARE CODE (“CODE”) ON AN AS-IS BASIS AND AUTHORIZES YOU TO USE THE CODE SUBJECT TO THE TERMS LISTED HEREIN. BY USING THE CODE, YOU AGREE TO THESE TERMS. YOUR USE OF THE CODE IS AT YOUR OWN RISK. JMP MAKES NO REPRESENTATION OR WARRANTY, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO, WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRIGEMENT, AND TITLE, WITH RESPECT TO THE CODE.
You may use the Code solely as part of a software product you currently have licensed from JMP, JMP’s parent company SAS Institute Inc. (“SAS”), or one of JMP’s or SAS’s subsidiaries or authorized agents (the “Software”), and not for any other purpose. The Code is designed to add functionality to the Software but has not necessarily been tested. Accordingly, JMP makes no representation or warranty that the Code will operate error-free. JMP is under no obligation to maintain, support, or continue to distribute the Code.
Neither JMP nor its licensors shall be liable to you or any third-party for any general, special, direct, indirect, consequential, incidental, or other damages whatsoever arising out of or related to your use or inability to use the Code, even if JMP has been advised of the possibility of such damages. Except as otherwise provided above, the Code is governed by the same agreement that governs the Software. If you do not have an existing agreement with JMP or SAS governing the Software, you may not use the Code.
JMP and all other JMP Statistical Discovery LLC product or service names are registered trademarks or trademarks of JMP Statistical Discovery LLC in the USA and other countries. ® indicates USA registration. Other brand and product names are registered trademarks or trademarks of their respective companies.
*/
Names Default To Here( 1 );
//get scripts to run
lstScripts = Files In Directory( "$Documents/My Scripts/" );
//set up stop button
nw = New Window( "Running",
Text Box( "Running all the scripts" ),
Button Box( "Cancel", Stop() )
);
For Each( {i}, lstScripts,
If( Word( -1, i, "." ) == "jsl", //make sure it's a .jsl file
include( "$Documents/My Scripts/" || Char( i ) ); //run it
Wait( 0 ); //this allows JMP to recognize if cancel button has been pressed
)
);
nw << close window;回复:如何编写一个 JSL 脚本来调用和运行其他脚本而不打开脚本窗口但只显示一个取消按钮?@Jed_Campbell谢谢,
我不清楚您的脚本(下面稍作修改的版本)如何调用路径中的主脚本。
在我的例子中,主脚本调用所有其他脚本。 这是我需要的功能。
此外,是否可以在脚本中生成的窗口 (nw) 中捕获并显示显示在我的主脚本上(底部)的日志。 就我而言,无论如何,原始脚本和修改后的脚本都不起作用。
Names Default To Here( 1 );
path2Scripts = "C:\Users\UserName\Documents\Scripts_v0.1.4"; //change this as necessary
//get scripts to run
lstScripts = Files In Directory(path2Scripts);
//set up stop button
nw = New Window( "Running", << modal,
Text Box( "Running all the scripts" ),
Button Box( "Cancel", Stop() )
);
For Each( {i}, lstScripts,
If( Word( -1, i, "." ) == "jsl", //make sure it's a .jsl file
include( path2Scripts || Char( i ) ); //run it
Wait( 0 ); //this allows JMP to recognize if cancel button has been pressed
)
);
nw << close window;我错过了什么?
回复:如何编写一个 JSL 脚本来调用和运行其他脚本而不打开脚本窗口但只显示一个取消按钮?啊,我想我误解了你原来的问题。 我提供的脚本既显示取消按钮又运行文件夹中的所有脚本。 如果我理解正确,您已经编写了运行所有其他脚本的脚本。 在这种情况下,此文件的脚本应如下所示:
//!
//the //! comment on the first line causes the script to run, rather than open
Names Default To Here (1);
clear log();
//set up stop button
nw = New Window( "Running", << modal,
Text Box( "Running all the scripts" ),
Button Box( "Cancel", Stop() )
);
include("path/to/main/scipt.jsl"); //your file that runs all the scripts
logtxt = get log();
您需要确保插入 wait(0);主脚本文件中的语句。 否则,JMP 可能不允许取消按钮起作用。
回复:如何编写一个 JSL 脚本来调用和运行其他脚本而不打开脚本窗口但只显示一个取消按钮?使 JSL 自动运行的关键是将其添加到脚本的第一行。
//!
如果双击脚本,它将运行并且不会打开脚本文件。
例如,在一个空脚本中传递它并保存它,然后双击它。
//!
Speak("ha, ha, I just ran a script.");如何编写 JSL 脚本来调用和运行其他脚本而不打开脚本窗口但只显示取消按钮?我想编写一个 JSL 脚本,比如 myScript.jsl,双击打开时它不会在脚本窗口中打开,而是运行在 myScript.jsl 内调用的其他脚本,同时显示一个显示“脚本运行”的模式窗口和一个用于停止的取消按钮进一步执行。
如果可以在 JSL 中做到这一点,能给我一个例子吗?
自动化和脚本编写