|
目前因为没有安装vb,所以是在excel中弄的。打开excel,按Alt + F11进入vb编辑器,双击左边的thisworkbook,在右边的空白处粘贴下面的代码,改路径,然后F5,或者一直F8,运行完成(提示success to transform)。文件保存在D:\23Out.sgf。
下次有时间用vb或者C#弄成对话框,再进一步完善一些细节,那就完美了。在xp,office2003下成功运行。
代码如下:
'实现qq围棋的wgs格式转为sgf通用格式可以被multigo3.5打开
'还存在一个问题:如果最后一手是黑下,那么将不转换最后一手,有空再改
'sgf的前后竟然有引号,不过也可以被打开,呵呵
Sub ReadWgs()
Dim fileName As String
Dim outputName As String
Dim allWgsContent() As Byte '用来读取文件的数组,每次读取前要重定义
Dim outputContent As String
fileName = "D:\test.wgs" '被转换的wgs文件
outputName = "D:\23Out.sgf" '生成的sgf文件
outputContent = "(;SZ[19]AP[MultiGo:3.5.0] "
Open fileName For Binary As #2
Open outputName For Output As #1
ReDim allWgsContent(LOF(2) - 1) '重定义数组,为读取文件做准备
Get #2, , allWgsContent() 'allWgsContent(120)=23,总手数
For i = 122 To LOF(2) - 4 Step 4
Dim bX As String '水平的x,向右为正,单位为4Deg black
Dim bY As String '垂直的y,向下为正,单位为1Deg
Dim wX As String 'white
Dim wY As String
Dim tempbwXY As String
bX = Chr(Int(allWgsContent(i)) / 4 + 97)
bY = Chr(Int(allWgsContent(i + 1)) + 97)
wX = Chr(Int(allWgsContent(i + 2)) / 4 + 97)
wY = Chr(Int(allWgsContent(i + 3)) + 97)
tempbwXY = " ;B[" & bX & bY & "] ;W[" & wX & wY & "]"
outputContent = outputContent & tempbwXY
Next i
outputContent = outputContent & ")"
Write #1, outputContent
Close #2
Close #1
MsgBox ("success to tranform")
End Sub
[em01] [em01] [em01] |
|