|
-
Aug 8th, 2000, 04:40 PM
#1
Thread Starter
New Member
Parsing a File one line at a time.
Here's the situation.
I load a text-based file into an invisible TextBox.(Lets call it TextBox1). I then need to read the information from TextBox1 one line at a time, then pass that line to another invisible TextBox (TextBox2), where i process the information in that line. Then i need to be able to jump to the next line in TextBox1 and repeat this till the last line in TextBox1.
Fine i thought, use Split with ChrS(13) and then just increment the the number to read the next line...
This works *basically* but is not what i want to achieve.
Maybe i should go into a little detail.... (Watches everyone click the back button )
I am making my own client for a game which already has a scripting language invented for it (Real easy language)
Now i want to be able to use the existing scripting language, and scripts, with my client. So in other words i'm just making an interpreter between the client and the script.
Now as i stated above, i need to load the script up, parse it 1 line at a time, and then process that line befre moving onto the next line.
One of the major commands of this script language gets in the way though, lemme show ya a small example of the script language so as to better understand.
---Snip!---
Put Look
Match SEEBOB You see Bob
Match SEEFRANK You see Frank
Match SEEJOE You see Joe
Matchwait
SEEBOB:
*more commands related to Bob*
SEEFRANK:
*more commands related to frank*
SEEJOE:
*more commands related to joe*
--Snip!--
The Put command simple sends everything after it to the game, just as you would type it (eg. 'put look' sends 'look' to the game)
Interpreting put should be no problem, it the next bit...
The Match command works like this...
Syntax : MATCH <subtogoto on succesful match> <text to match>
So 'MATCH SEEBOB You see Bob' Would take me to the Sub defined as 'SEEBOB:' when the 'You see Bob' text appears in the actual viewing screen (RichTextBox1 for arguments sake).
By the way, the MATCHWAIT command simply waits until one of the above MATCHes is met.
You can probably see my problem now. I need to parse the Text from the Script line by line, process it, then continue onto the next line. But if i bump into a match command i need to make variables from the 2 Strings after it, then wait for a MATCHWAIT before i process it, then jump to the Corresponding Section on a successful match (Much like VB command Goto)
*Scream!*
Any help on this would be most appreciated, as I wrote down a rough idea of what i needed to do, blinked, then see above section marked *Scream!* 
There's gotta be some 'not-as-longwinded-as-it-looks' type code that could be made to do what i wish.
Thanks for any help on this topic, and sorry for having such a longwinded post, but i like to explain EXACTLY what i am looking for before asking anyone for help.
Regards,
David Perry
VB6 Enterprise SP4
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|