using rdotnet;
using rdotnet.nativelibrary;
using statconnectorclntlib;
using statconnectorcommonlib;
using statconnectorsrvlib;
下面是基於winform的示例**,
public partial class formcalculate : form
private void formimportdata_load(object sender, eventargs e)
catch (exception ex)
//thread thread = new thread(new threadstart(backgrounddeal));
}private void backgrounddeal(object sender, doworkeventargs e)
#endregion
#region 執行指令碼
this.tslblmsg.text = "正在執行指令碼語言...";
//symbolicexpression tt;
engine.evaluate(string.format("source('')", rscript));
#endregion
#region 顯示資料
this.tslblmsg.text = "正在載入處理結果...";
if (!file.exists(filename))
string extision = system.io.path.getextension(filename);
if (extision.tolower().equals(".csv"))//csv檔案
else//excel檔案
this.invoke(new action(delegate)", data_old.rows.count);
}));
#endregion
this.tslblmsg.text = "";
}catch (exception ex)
}private void runcompleted(object sender,runworkercompletedeventargs e)
/// /// 開始處理
///
///
///
private void toolstripbutton1_click(object sender, eventargs e)
);"greetings", charvec);
"str(greetings)"); // print out in the console
//string a = engine.evaluate("『hi there .net, from the r engine『").ascharacter().tostring();
// statconnector sc1 = new statconnectorsrvlib.statconnectorclass();
symbolicexpression tt;
try')", rscript));
messagebox.show("計算完成");
}catch (exception ex)
#endregion
//symbolicexpression tt = engine.evaluate("license()");//有返回值
//symbolicexpression tt= engine.evaluate(string.format("source('')", rscript));
"計算完成");
}catch (exception ex)
}/// /// 返回datatable的前nrow行
///
///
///
///
private datatable getsubsetfromdatatable(datatable dt,int nrow)
return table;
}/// /// 檢視結果
///
///
///
private void tsbtnrenew_click(object sender, eventargs e)
string extision = system.io.path.getextension(filename);
if (extision.tolower().equals(".csv"))//csv檔案
else//excel檔案
this.dgvdata.datasource = data_old;
= string.format("處理結果()", data_old.rows.count);
}catch (exception ex)
}private void dgvdata_sortcompare(object sender, datagridviewsortcompareeventargs e)
}
命令列執行C檔案示例
先寫乙個c語言 檔案mstore.c內容如下 include long mult2 long long void multstore long x,long y,long dest 在命令列使用 s 選項,就能看到c語言編譯器產生的彙編 ps e vs code vs code c chapter ...
簡單C 事件示例
熱水器開始對水加熱,當水加熱到95度以上的時候,熱水器的報警器開始報警,並且在螢幕上顯示當前的水溫。不難從上面的這一小段話看到,要想模擬該程式,需要乙個熱水器物件heater,報警器物件alarm,顯示器物件display。下面邊上 邊解釋吧。熱水器類,用來燒水的 class heater publ...
C語言多原始檔編譯簡單示例
首先我們開啟c語言環境 本例子用的linux系統下gcc直接編譯 建立3個檔案,分別為main.c a.c a.h 先在a.c檔案裡寫兩個簡單點函式。如下 int max int a,int b intadd int a,int b 再在a.件裡面宣告這兩個函式。如下 int max int a,i...