各位,
我請求您就以下主題提供專家建議,因為我對 JMP 腳本編寫非常陌生。
我透過查詢產生器進行了 SQL 查詢(不可見),但我需要幫助來:
- 提示使用者插入資料表文件名稱(彈出視窗);
- 新增日期和時間( ddmonyyyy:時:分:秒) 到輸出資料表
我設法編寫的腳本如下:
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
腳本的執行很可能在 New Query(.
嘗試在前台而不是背景執行查詢,或在查詢之前使用模態從使用者取得值,並在查詢完成後使用 postquery 腳本變更名稱。
感謝您的回覆!
我在這個級別仍然有一個問題:
dt << set name( nw["tableName"] );
我收到的錯誤訊息如下

你能幫我解決一下嗎?
再次感謝,
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);