Parsing a .txt file to check consistency between several files

R

RedFox

Hello, I'm a beginner at Visual Basic and desperately need to develop a
program to help with game developing. The idea of the program is simple - to
cross check across various files for consistency and make sure certain
conditions are met. Lines that do not check would be echoed into an error
dialog or form.

There are 3 files in which the program must check. The main file is called
'descr_strat.txt'. This file is littered with thousands of lines of code and
it must check for the following lines:

faction greek_cities,
....
unit greek levy hoplites exp 1 armour 0 weapon_lvl 1
....

First it should find a line with 'faction' and identify the faction as
'greek_cities', then the next line with 'unit' should be identified as 'greek
levy hoplites' belonging to 'greek_cities' with culture 'greek'
Once the unit is identified, the program must check another file for the
correct ownership value: export_descr_unit.txt

type greek levy hoplites
....
....
ownership greek

It should find the unit type 'greek levy hoplites' and check the next line
of ownership that comes up. This value should return as 'greek', also meaning
'greek_cities'.
There is also a third file that defines each faction's culture. Since the
ownership can be both a faction name and culture, it must check for either of
those. For example, the ownership can be "ownership greek_cities" or
"ownership roman, eastern, greek_cities". In either way, it must identify all
the values there and check if it adds up to the faction in descr_strat.txt
The culture file is pretty basic and self explanatory:
....
greek_cities=greek
romans_julii=roman
....

Now I know that this is a bit TOO complex to start with when you just
started learning Visual Basic, but we really need this program to debug the
game, since incorrect ownerships cause a crash and there are THOUSANDS of
unit lines in that file, and manual checking would take days.
The idea itself seems really basic, I just need to know how to make VB to
open those files, then search and check for the necessary data.

Regards,
- RedFox
 
C

Cor Ligthert[MVP]

RedFox,

I don't give you the fish, however here some things to catch the fish.

First something about Visual Basic itself. Visual Basic is a language with
an extended code set which exist already many years.
Some of the language is named in VB functions like Mid, Find etc. They are
working well and are an integrated part of the Net Framework

However, now that Visual Basic is a full OOP language, we can as well use
the methods as those are created in a class and used in the same way in
other Net program languages.

A textfile is nothing more than a string where ever line is seperated by the
characters which can be found with the Visual Basic keyword VBCrLF.

A string is a class with an extended set of methods. Have a look at those,
for your problem you can use by instance indexof and substring

http://msdn.microsoft.com/en-us/library/system.string_members.aspx

I hope this helps,

Cor
 
R

RedFox

Thank you very much! This was exactly the type of help I was looking for. I
doubt I could've found my way to the String Members page with all the
commands I need.

I will try to figure out the rest myself for now and if I run into a dead
end I'll be sure to post here again :)

Regards,
- RedFox
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top