close


這是2005/1/3:
2005/01/03
編寫Ruby執行檔製作精靈這個計畫已經很久了
自從我第一眼見到Ruby這個語言,我就很喜歡它
當我看到這程式要編譯成執行檔,步驟複雜又難懂
而且還很容易錯誤
因此,我打算用Visual Basic 6.0 Professional版來編寫一個執行檔製作精靈(因為本身對Ruby這個語言還不熟,用C語言光是介面就很難搞,不過未來可能推出C語言版)

今天是第一次進行編寫工作,因為在這之前並沒有做好完善的規劃,所以只好一邊寫一邊修....

介面大致上完成,原始碼部分完成度有將近85%,但是Debug的時候還是發現許多Bug,所以在0.0.1這個測試版功能正常之前應該不會推出0.0.2正式版

下面是第一次編寫的原始碼

Private Sub compile_Click()
On Error GoTo err '發生錯誤跳到err標籤
Dim rbfilename$, rubypath$, sourcepath$ '宣告三個字串變數,分別為檔案名稱、Ruby執行檔位置、原始檔存放的資料夾

If filedir.Text = "" Then MsgBox "請輸入檔案名稱。", , "Ruby執行檔精靈" '如果檔案名稱為空白的話,那就跳出警訊方塊
rbfilename = Trim(Str(filedir.Text)) '將文字框內的檔案名稱去掉頭尾的空白之後轉成字串型態再存入rbfilename變數
rubypath = dirs.Path '將Ruby安裝位置存入rubypath變數
sourcepath = sourcedir.Path '將原始碼位置存入sourcepath變數
Shell "cmd.exe /c echo cd" & sourcepath '使用命令列進行切換原始碼所在目錄
Shell "cmd.exe /c echo " & sourcedisk.Drive '跳到原始碼所在目錄
Shell "cmd.exe /c echo " & rubypath & "uby -r exerb mkexr " & rbfilename & ".rb" '開始進行編譯步驟1:製造exr檔案跟mak檔案
If gui(0).Value Then '判斷是否為GUI介面程式
Shell "cmd.exe /c echo " & rubypath & " " & disk.Drive & "mingwusrlocalinexerb -c gui" & " " & rbfilename & ".exr" '如果是,加入GUI程式編譯參數,以防程式未來執行時跳出命令列視窗
Else
Shell "cmd.exe /c echo " & rubypath & " " & disk.Drive & "mingwusrlocalinexerb" & " " & rbfilename & ".exr" '如果不是GUI程式,就直接編譯
End If
err:
End Sub

Private Sub disk_Change()
dirs.Path = disk.Drive

End Sub

Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
MsgBox "本程式為CFC@Zuso Security編譯製作。", , "Ruby執行檔精靈"
End Sub

Private Sub quit_Click()
MsgBox "本程式為CFC@Zuso Security編譯製作。", , "Ruby執行檔精靈"
End
End Sub

Private Sub sourcedisk_Change()
sourcedir.Path = sourcedisk.Drive
End Sub


使用的物件有DriverListBox, DirsListBox, Text, Label, Command Button, Option Button, Frame
arrow
arrow
    全站熱搜

    hechian 發表在 痞客邦 留言(0) 人氣()