Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Newcomers DBPro Corner / Parsing text files

Author
Message
roswell
21
Years of Service
User Offline
Joined: 17th Dec 2002
Location: United States
Posted: 25th May 2004 01:12
I'm looking into what it would take to create a game viewer to read SGF game records for games like Chess and Go. The game records have seem pretty simple by human standards, but parsing it is a bit more complicated. Here's an example:

(;PW[roswell1329]PB[chochikun];B[ea];w[ac];B[qq]C[Interesting move here...](;B[qs]C[Better?]);W[tt])

Does anyone know how I would approach this sort of task in DBPro? Would I need to read in the string character by character and keep track of the number of open and closed brackets and parentheses, or is there a higher method of parsing through a string?

/* You are not expected to understand this. */

Dual Athlon 2.0/1GB RAM/GeForce Ti4200-128/Win2000 Pro
CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 25th May 2004 01:29 Edited at: 25th May 2004 01:31
our plugin has some nifty vb.net string functions including Split and Mid, that may help you in your endeavour

we also just made the latest newsletter

edit: based on your example, would splitting on the semicolon be helpful? If yes then definitely get our plugin


* DBP_NETLIB_v1.1 - VB.NET PLUGIN FOR DBP * Click Logo
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 25th May 2004 02:54
check the code base for my string tokenizer. IMO, that looks like a sloppy way of writing data.

"eureka" - Archimedes
roswell
21
Years of Service
User Offline
Joined: 17th Dec 2002
Location: United States
Posted: 25th May 2004 04:59 Edited at: 25th May 2004 05:00
It's not really a sloppy way of coding, it's just a system that has grown over time. It looks like there is some movement toward an XML based method which would be a much more modern way of storing the information, but XML isn't any easier to parse in BASIC than the EBNF standard that SGF files use now. EBNF is just an older markup language.

As for the semi-colons, yes that would work just fine, but there are some other conditions. Breaking up the string on semi-colons would seperate out each move, but then you have to break up each move into property types, of which there may be several per move. It sounds like your plugin might work, CattleRustler. However, if you coded it in VB, did you use a function that reads the string in character by character, or did you build yourself some pattern-matching functions?

/* You are not expected to understand this. */

Dual Athlon 2.0/1GB RAM/GeForce Ti4200-128/Win2000 Pro
CattleRustler
Retired Moderator
21
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 25th May 2004 05:25
the plugin is written in VB.NET. Some of the functions are just wrapped vb.net functions, some are, at the core, a vb.net function, but with some added code to help it along to be able to play nice with DBP. If you click my logo below the page you come to has a link pointing to the user document. Look through the string functions as everything is fully documented. Maybe something will make your life easier there but I suspect you will need to write your own parser - hopefully our plugin can help in that effort as it employs many powerful string functions from vb.net (above and beyond anything found in vb6). If you want to recommend something to us (like a parser of some sort) then feel free to explain and maybe we can add it. On the XML note, I remember writing a class in VB6 that parsed xml, and it was nothing more than cleverly used vb6 commands (INSTR, MID,LEFT RIGHT, INSTRREV, etc) all of which are found in our plugin. .net has XML classes (including parsers, stream readers) so that may be something we could add to our plugin.




* DBP_NETLIB_v1.1 - VB.NET PLUGIN FOR DBP * Click Logo

Login to post a reply

Server time is: 2024-11-26 18:19:54
Your offset time is: 2024-11-26 18:19:54