File Handling
Displaying 1-11 of 11 total.
1
Please enter a numerical value for the importance of this sticky.
Enter 0 to unsticky.
Zip

Seeing as this is going to be a requirement for HoV, and Grue has promised to help out with save/load is needed, how about the File Functions documentation gets finished sometime soon? Stuff like 'you can't use FileSeekLine' if the file is opened in write mode, or verge will bomb' would be useful. And how you do write to a specific line without that would be nice too.

Zip

Posted on 2004-06-22 01:11:27

mcgrue

Errmm...

...uh...

...vec? zero? wanna finish up the docs over there? :(

Posted on 2004-06-22 18:38:00

Zip

People certainly have /ignore zip.

Ah well, back to proper programming and compilers that give the right line number on error.

Zip

Posted on 2004-06-22 19:48:16

mcgrue

aroo?

Zip, I've been finding your comments in the docs to be quite helpful. If you notice, I usually rectify problems you report on the talkback pages as soon as I get the moderation notice.

Thank you for your support.

  </bartles>
</james>

Posted on 2004-06-22 20:30:21 (last edited on 2004-06-22 21:41:59)

vecna

I actually just fixed a bug that would sometimes cause the vcerr() routine that performs reverse-lookups to crash rather than deliver the appropriate error message. Now, FileSeekLine on a write-mode file will return the error message written for it. But you are not intended to be able to FileSeekLine on a write-mode file. Note that verge doesnt do "read-write" file mode.. you're either reading or writing. Therefore seeking to an existing line doesnt really make sense. In general.. you're supposed to write the file in order. If you really want to be able to seek around inside a file while you're writing it, make it a binary file and use FileWriteString and such instead. FileSeekPos() will work in read or write mode. But to make FileSeekLine work on write mode would require the ability to append lines to the end of the file, and for write operations to - overwrite? insert? to existing lines... it would be messy. Using binary file functions will expect you to know what you're doing.

Newest exe is always here.

Posted on 2004-06-23 05:49:24 (last edited on 2004-06-23 05:49:51)

Zip

@Grue - I help where I can, but too much of vc is still a mystery to me. Generally experimenting clarifies things, but that takes quite a bit of time, and when you just want to know how to do something I can do in c++ it breaks your programming rhythm.

@vec - Thanks that clarifies thing a little. However, I still can't get a basic log style writing function to work.
dd_dump = FileOpen("dump\data.txt", FILE_WRITE);

FileSeekPos(dd_dump, 0, SEEK_END);
FileWrite(dd_dump, dd_dumpstr); // or FileWriteln/FileWriteString
FileClose(dd_dump);

This just overwrites from the beginning of the file each time - is SEEK_END not implemented yet?
dd_dump = FileOpen("dump\data.txt", FILE_WRITE);

FileSeekPos(dd_dump, DumpEndOfFile, SEEK_SET);
FileWrite(dd_dump, dd_dumpstr); // or FileWriteln/FileWriteString
DumpEndOfFile = FileCurrentPos(dd_dump);
FileClose(dd_dump);

This just writes blanks over anything writen up to that point, so the output is "data1" then " data2". Reading in the entire file to a string then writing it again with a little bit extra on the end doesn't seem a good solution to me.

Also, how can I put a newline character in my strings? None of the standard \0 \r \n work.

Finally, is there any trick to understanding which line number verge actuall means with 'system.vc(75): some error' - 'cos the one thing you can guarentee is it ain't line 75.

Thanks,

Zip

Posted on 2004-06-23 13:14:39

Gayo

The line numbers are just randomly off, I think -- if there were any easy pattern to it, I'm sure it'd have been fixed by now. What I do is enter a blank line in the middle of the code and recompile, and if that increases the line reported for the error, I know the error is below the blank line. Then I delete it and add another blank line lower down, and so on, like that game where you guess a number and the person says if it's too high or too low.

Posted on 2004-06-28 09:38:05 (last edited on 2004-06-28 09:43:22)

Kildorf

I've been finding that the line numbers it gives usually have a little bit of a pattern:

They are pretty consistently after the error.
The generally manage to fall in the same function as the error.

Aside from that, the only advice I can offer is that they're usually somewhere between 1 and 15 lines off. If you're using small little functions like you're supposed to then this doesn't really help more than the "same function" generality, but if you program like me when I'm in a hurry, then it can be a help.

Unfortunately, none of these are hard fast rules. I'm pretty sure I have encountered various situations where any or all of those three patterns are broken.

It makes debugging an adventure!

Posted on 2004-06-28 11:54:45

Zip

I notice if I'm lazy with putting my {} in right I'm in for a world of pain = errors given in functions miles away, very little hint of where the problem is. But it's nothing like some of the variable nameing bugs I've had in c.

Thanks for the tips guys, this should speed things up - I was commenting the body of every function and seeing it let me put back in.

Zip

Posted on 2004-06-28 12:50:54

vecna

I just want to add that I am looking into the line numbers situation. While its more or less unavoidable with the way VC works for the line numbers to be off by about 1 line (and yes, usually after the error), that should really be the theoretical maximum that the line number should be off - or at absolute worst, the line number that the next code statement occurs on (because it may not realize that you're missing what it expects until it gets to the next statement). When the line number is off by like 15, thats an indication of a serious and unintended bug.

Posted on 2004-06-29 22:39:22

Zip

Don't know if this will help at all Vec, but it was odd so I thought I'd post it.
This code (unsurprisingly) give me a ';' expected error on line 144 (is infact line 127):
	SetRandSeed(fr_seed);

fr_h1 += 360(;
fr_h2 += 360;

Press enter after the rand seed line and save it gives error on line 145:
	SetRandSeed(fr_seed);


fr_h1 += 360(;
fr_h2 += 360;

But then, and this is the funky thing, if instead you press enter just before the fr_h1 and save it gives an error on line 146!:
	SetRandSeed(fr_seed);


fr_h1 += 360(;
fr_h2 += 360;

Now that looks identical to me, both here and in textpad, do din the difference and that'll probably help.

Zip

Posted on 2004-06-29 23:40:32


Displaying 1-11 of 11 total.
1
 
Newest messages

Ben McGraw's lovingly crafted this website from scratch for years.
It's a lot prettier this go around because of Jon Wofford.
Verge-rpg.com is a member of the lunarnet irc network, and would like to take this opportunity to remind you that regardless how babies taste, it is wrong to eat them.