Going to a position in a file

BlitzMax Forums/BlitzMax Beginners Area/Going to a position in a file

Mordax_Praetorian(Posted 2006) [#1]
Ok, so now I'm coding my own little scripting language, and once again I find the help file to be extremely lacking

I've opened a file using Open File, and gone the entire way down using ReadLine in order to gather information to set parameters needed for the script to work

I now need to find lines beginning with various sets of characters, and move the "cursor" as it were reading the file back to them

The help file was not helpful, I found what I think is the right command, "Seek Stream" but failed to understand the explanation of how to use it


SculptureOfSoul(Posted 2006) [#2]
Well, I'd personally recommend that you learn to use a fully functional scripting language.

Lua will prove to be faster and more functional than any scripting language a novice to scripting languages can cook up (no offense intended...I was considering implementing my own until I realized how much of a time waste it would be).

Sorry I can't be of more help. Honestly, though, I think this is an area where it'd be much more beneficial to learn LUA and then when the day comes when you need a feature that LUA or another popular scripting language can't provide (if that day ever comes...I mean, most AAA titles are using LUA, Python or Ruby), then you can implement your own.


tonyg(Posted 2006) [#3]
Seekstream will position the 'cursor' POS bytes from the start of the stream as long it is seekable. A stream is seekable if the size of the stream is known.
I'm doing something similar reading a .doc which keeps all it's text in a single area resulting in a huge readline.
I then have to Seekstream(mystream,xxx) to position the cursor to the start of the text area and then know whether to readint or readstring etc. It's a pain.
Not sure if it helps.


Mordax_Praetorian(Posted 2006) [#4]
that does indeed help

SculptureOfSoul:

When LUA can call an NPC block I'll use it, but fact is that nothing made by anyone else is going to be easily interface with the engine, and I have an easy method to have the scripting language develop as the engine does with little extra time.... If I can find all of the commands of course

Its all a matter of how you look at it

Every time I make a new system, all I have to do is add a few commands to the script reader to be able to manipulate that system, filling in for what I've already done isnt too hard, I'm a good way through it already

Given the circumstances, getting the engine to interface with someone elses script language would be far less practical


Mordax_Praetorian(Posted 2006) [#5]
Ok, 3 more questions

If I call one of the write commands, does this overwrite the data that would otherwise be infront of the cursor, or add the data where the cursor is?

When I call Readline does this bring the cursor to the end of the line or the start of the next?

Is there a good method for moving the cursor back a single character or do I have to do it the hard slow way?


Dreamora(Posted 2006) [#6]
Readline: Goes to next line as it reads until and including the line break.

Write overwrites the previously written bytes. If you want to extend it you must take care of that by rewriting all following bytes.

There is only one way and thats repositioning the cursor one position before the actual one. Don't see why this should be slow.


Mordax_Praetorian(Posted 2006) [#7]
Aha, so 1 postition is 1 character?

I get it now

And the Line Break is counted as a character as well right?

Edit:

Which syntax is correct?
SeekStream(Area,StreamPos(Area)-2)
or
StreamPos(Area) = StreamPos(Area)-2