各位,
我正在就以下主题征求您的专家意见,因为我对 JMP 脚本编写非常陌生。
我通过查询构建器进行了 SQL 查询(不可见),但我需要帮助:
- 提示用户插入数据表文件名称(弹出窗口);
- 添加日期和时间( ddmonyyyy:h:m:s ) 到输出数据表
我设法编写的脚本如下:
Names Default To Here( 1 );
dt=New SQL Query(
Version( 130 ),
Connection(
"ODBC:DSN=DB001.00.G_FE_JMP15;DBQ=Y:\OFFICIAL_DATABASES\QA_Admin\Stability\DB001.00.G.StabilityStudies_FE_StudiesCompiler_JMP15.accdb;DriverId=25;FIL=MS Access;MaxBufferSize=2048;PageTimeout=5;UID=admin;"
),
QueryName( "Query_DB001.00.G.StabilityStudies_FE_StudiesCompiler_10Jun2021" ),
Select(
Column( "StudyID", "t1" ),
Column( "TimePointID", "t1" ),
Column( "StabilityClimaticConditions", "t1" ),
Column( "TestMonth", "t1" ),
Column( "ProgramComments", "t1" ),
Column( "Test1", "t1" ),
Column( "Test1Specification", "t1" ),
Column( "Test1Units", "t1" ),
Column( "Test 01", "t1" ),
Column( "intTest1", "t1" ),
Column( "Test2", "t1" ),
Column( "Test2Specification", "t1" ),
Column( "Test2Units", "t1" ),
Column( "Test 02", "t1" ),
Column( "intTest2", "t1" ),
Column( "Test3", "t1" ),
Column( "Test3Specification", "t1" ),
Column( "Test3Units", "t1" ),
Column( "Test 03", "t1" ),
Column( "intTest3", "t1" ),
Column( "Test4", "t1" ),
Column( "Test4Specification", "t1" ),
Column( "Test4Units", "t1" ),
Column( "Test 04", "t1" ),
Column( "intTest4", "t1" ),
Column( "Test5", "t1" ),
Column( "Test5Specification", "t1" ),
Column( "Test5Units", "t1" ),
Column( "Test 05", "t1" ),
Column( "intTest5", "t1" ),
From( Table( "qry_ResultsUnion01_35", Alias( "t1" ) ) ),
Where(
EQ(
Column( "StudyID", "t1" ),
_AllRows_,
UI(
Comparison(
Base(
"Continuous",
Prompt(
"StudyID:",
Character,
PromptName( "t1.StudyID_1" )
)
)
)
)
) & In List(
Column( "StabilityClimaticConditions", "t1" ),
_AllRows_,
UI(
SelectListFilter(
ListBox,
Base(
"Categorical",
Prompt(
"StabilityClimaticConditions:",
Character,
PromptName( "t1.StabilityClimaticConditions_1" )
)
)
)
)
)
)
) << Run Background(invisible);
nw = New Window( "Name data table",
<<MODAL></MODAL>非常感谢,
F
尝试将最后一个 if 语句更改为此,它既修复了 tableName 引用,又删除了可能导致问题的斜杠和冒号:
//ask where to save the file (could skip this or define it in code)
fldr = pick directory( "Select where to save the file", "$Temp" );
//Save the file
If( nw["button"] == 1 & nw["tableName"] != "",
dt << set name( nw["tableName"] );
dt << save as( fldr || nw["tableName"] || Format Date( Today(), "yyyymmdd" ) || "-" || Char( Hour( Today() ) ) || Char( Minute( Today() ) ) || Char( Second( Today() ) ) || ".jmp");
);
//Open directory where file was saved (not needed)
Open(fldr);
感谢您的回复!
我在这个级别仍然有一个问题:
dt << set name( nw["tableName"] );
我得到的错误信息在下面

你能帮我解决吗?
再次感谢,
F
脚本的执行很可能在 New Query(.
尝试在前台而不是后台运行查询或在查询之前使用模态从用户获取值并在查询完成后使用 postquery 脚本更改名称。