.com.unity Forums
  The Official e-Store of Shrapnel Games

This Month's Specials

The Falklands War: 1982- Save $9.00
winSPMBT: Main Battle Tank- Save $5.00

   







Go Back   .com.unity Forums > Shrapnel Community > Space Empires: Starfury

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #19  
Old June 17th, 2004, 06:24 PM
Ed Kolis's Avatar

Ed Kolis Ed Kolis is offline
General
 
Join Date: Apr 2001
Location: Cincinnati, Ohio, USA
Posts: 4,547
Thanks: 1
Thanked 7 Times in 5 Posts
Ed Kolis is on a distinguished road
Default Re: Modding Tools

Well, my code's in C#, and while I could convert it to VB.NET, that wouldn't do much good as you're using VB6 which is radically different...

But basically, I have a structure called Field, which contains 2 strings, Name and Data.

Then to read the next field from a data file, I use this function:

code:
/// <summary>
/// Reads a data field from an SE4 text file and verifies its name if the
/// name parameter is not null.
/// </summary>
protected Field ReadFieldText(string name)
{
string line;
Field field;

// Read lines until a non-blank line is found
// Note that this is "nicer" than SE4's parser, in that
// extra newlines between lines are simply ignored, and the
// later entries are still read
// Find the first delimiter
int delimiterPosition;
do
{
// Read the next line from the data file
line = textReader.ReadLine();
delimiterPosition = line.IndexOf(delimiter);
} while (delimiterPosition < 0); // read until good line found

// Create the field
field = new Field(line.Substring(0, delimiterPosition).Trim(),
line.Substring(delimiterPosition + delimiter.Length).Trim());

// Verify if necessary
if (name != null && field.Name != name)
throw new ParserException("The field name \"" + field.Name + "\" was found where \"" + name + "\" was expected.", line);

return field;
}

The ParserException is just an exception class I created so I can tell a parser exception from any other type of exception.

This particular implementation will verify that the name of the field is some specific value, so you can make sure the fields are in the right order. Or, if you pass a null reference (does VB6 have those?), it won't verify and just return the next field no matter what.

Would you find everything I've worked on handy, even though it's in C#? I can post it on my website if you want...
__________________
The Ed draws near! What dost thou deaux?
Reply With Quote
 

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT -4. The time now is 09:46 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Copyright ©1999 - 2026, Shrapnel Games, Inc. - All Rights Reserved.