Computer Chess Club Archives


Search

Terms

Messages

Subject: A little experiment: WinBoard and Visual Basic

Author: Luca Dormio

Date: 06:43:28 07/16/99


This topic was discussed some days ago in the italian newsgroup it.hobby.scacchi
(scacchi=chess); since i was interested in making some chess related stuff in VB
such as an interface for winboard engines and/or a conversion of a simple engine
from another language i've recently started some tests on communication
protocol.
Following some of the tips in winboard's "engine-intf.txt" i was able to
establish a link between WB and a fake engine written in VB; here's how:

'==== VB code ====
'Retrieve standard input/output handles
hStdIn = GetStdHandle(STD_INPUT_HANDLE)
hStdOut = GetStdHandle(STD_OUTPUT_HANDLE)

Do While Not StopEngine
   'poll for input
   rc = PeekNamedPipe(hStdIn, ByVal sBuff, 256, lBytesRead,
lTotalBytes,lAvailBytes)

   If rc And (lBytesRead > 0) Then
     'there's something new to read...
     rc = ReadFile(hStdIn, ByVal sBuff, 256, lBytesRead, ByVal 0&)
     If rc And (lBytesRead > 0) Then
        WinBoardInput = Left$(sBuff, lBytesRead)
        [...]
     end if
   End If
Loop

this part works fine, WB starts correctly my program and i receive every input
from it; the problem is that i can't send a command back to WB, i've tried with:

CommandStr = CommandStr & vbLf 'terminate command with a \n
lBytes = LenB(CommandStr)
rc = WriteFile(hStdOut, ByVal CommandStr, lBytes, lBytesWritten, ByVal 0&)

and with:

CommandStr = CommandStr & vbLf 'terminate command with a \n
lBytes = LenB(CommandStr)
SetFilePointer hStdOut, 0&, 0&, FILE_BEGIN
rc = WriteFile(hStdOut, ByVal CommandStr, lBytes, lBytesWritten, ByVal 0&)
SetEndOfFile hStdOut

but doesn't work either way, WB doesn't react to my command string (without
showing any warning); since the WriteFile API returns 0 (success) i probably
fail to do something else, any advice?

Thanks in advance
Luca



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.