你好,
我正在試圖編寫一個腳本,根據“新窗口”提供的不同值重新運行。
這是方案:
1 /我打開一個帶有按鈕的窗口(“選擇主文件”)。
2 /當我單擊此按鈕時,會啟動“選擇文件”,然後選擇一個文件
3 /根據所選文件的內容,我應該運行一個腳本並生成圖形
這是我的問題:
1 /每次選擇新文件時如何製作,重新運行整個腳本並更新圖形?
2 /如何在我選擇文件的“新窗口”中嵌入圖形?
3 /我必須運行的腳本相當長,必須生成幾個圖表。有沒有辦法調用這個腳本而不將所有代碼放在“新窗口”代碼中?(比如調用一個函數左右,......)
非常感謝。
在下面找到代碼的簡化版本(附帶2個文件來測試代碼):
// Collect location of the Master file and the data...
New Window( "Window Controls",
Lineup Box( N Col( 1 ), Spacing( 3 ),
Panel Box( "1/ Select location of Data...", Button Box( "Select Data", Folder = Pick Directory( "Please pick a folder", ShowFiles ) ) ),
Panel Box( "2/ Select Data Master File...", g1=Button Box( "Select Master File", MasterFile = Pick File()
) ),
Col List Box( all ); //g1 << updateWindow;
),
);
MasterTable = Open( MasterFile );
Lots = Column( MasterTable, "Lot" ) << GetAsMatrix;
Factors = Column( MasterTable, "Factor" ) << GetAsMatrix;
x = Factors * [10, 50, 90];
y = Factors * [10, 90, 10];
New Window( "Poly Seg Example", g = Graph Box( Poly Seg( x, y ) ) );
這是將圖形保存為表達式的一種方法,然後在新窗口中使用它。
dt = open("$sample_data\Big Class.jmp");
g1_expr = expr(
gb1 = dt << Graph Builder(Show Control Panel( 0 ),
Variables( X( :weight ), Y( :height ), Overlay( :sex ) ),
Elements( Points( X, Y, Legend( 6 ) ) )
);
);
g2_expr = expr(
gb2 = dt << Graph Builder(Show Control Panel( 0 ),
Variables( X( :age ) ),
Elements( Pie( X, Legend( 3 ), Label( "Label by Value" ) ) ),
SendToReport( Dispatch( {}, "Y title", TextEditBox, {Set Wrap( 2 )} ) )
);
);
nw = new window("Sample Graphs",
hlistbox(
g1_expr,
g2_expr
),
);