各位,
我正在就以下主題尋求您的專家建議,因為我對 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 腳本更改名稱。