2010年12月1日 星期三

BCB 使用GSL 函式庫

Step1: 下載libgsl.dll, libgslcblas.dll (ver. 1.8)以及相關.h檔。
Step2: 使用BCB提供的implib.exe製作lib 檔。
其實從google中可以搜尋到許多相關內容,但是我發現它們的教學我使用後會出現若干錯誤,
>implib -af libgsl.lib libgsl.dll
Borland Implib Version 3.0.22 Copyright (c) 1991, 2000 Inprise Corporation
Warning duplicate symbol: _gsl_sf_bessel_i0_scaled
Warning duplicate symbol: _gsl_sf_bessel_i0_scaled_e

...
我的作法是
implib加上-a -c -f 三個參數,(ref: 蕭沖的書房)
ex:
implib -a -c -f libgsl.lib libgsl.dll
很好,沒有出現錯誤。
在BCB6.0上使用上也都正常。

Step3: 加入BCB中使用,將製作完成的libgsl.lib與libgslcblas.lib加入專案,project->add to project->選擇libgsl.lib與libgslcblas.lib->OK

Step4: 加入相關函式的h檔,即可使用該函式。

2010年9月1日 星期三

MySQL Workench 5.2.27 CE 使用問題

使用新版Workbench時
在使用Update or Delete statement 時會出現
Error Code: 1175
You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column
儘管SQL內已經包含WHERE條件式。

safe update mode是避免錯誤更改到資料表內容,強制SQL內需要包含條件式,MySQL預設是關閉的。

解決辦法:
menu->edit->preference->SQL edit->取消
Forbid UPDATE and DELETE statements without a WHERE clause (safe updates) 的選項。
就可以正常執行了。

應該是新版本的Bug吧? 相信很快就會修正了。

新版本的Workbench也有依些修改,例如要執行全部SQL script時不在只要按ctrl+enter而是改為ctrl+shift+enter,執行單行仍然是ctrl+enter。

2010年8月1日 星期日

[Matlab] How to Connect MySQL with JDBC

  1. 到mysql官網下載connector/J
  2. 將其中的 mysql-connector-java-x.x.xx-bin.jar 解壓縮到 matlabroot目錄下的任何資料夾內(ex: $MatlabRoot\java\jconnector\)
  3. 打開$MatlabRoot\toolbox\classpath.txt 並將 mysql-connector-java-x.x.xx-bin.jar的路徑加入檔案內。
  4. 重新啟動matlab
  5. 用法:conn=database('db','user','password','com.mysql.jdbc.Driver','jdbc:mysql://localhost:3306/db')

2010年7月29日 星期四

JavaScript 字串去除空白

  • method 1
function trim(s) {
return s.replace(/^\s*|\s*$/g,"")
}
  • method 2
// Author: Ariel Flesler
// http://flesler.blogspot.com/2008/11/fast-trim-function-for-javascript.html
// Licensed under BSD
function myBestTrim(str) {
var start = -1, end = str.length; while (str.charCodeAt(--end)
while (str.charCodeAt(++start)
return str.slice(start, end + 1);
};