Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / File Append and Logging

Author
Message
Zerk
17
Years of Service
User Offline
Joined: 13th May 2006
Location: Orbiting Jupiter
Posted: 16th Jul 2006 01:04
I'm trying to write some logging functions to write debugging logs.

First off, it's very strange that there is not an append file function for opening an existing file and appending a string to it. This would be useful for writting log files.

Does anybody know a way around this or a way of writting log files?

I am putting myself to the fullest possible use, which is all I think that any conscious entity can ever hope to do. ~Hal-9000
Underworld 1020
20
Years of Service
User Offline
Joined: 2nd Mar 2004
Location: NY, USA
Posted: 16th Jul 2006 09:09
I agree there should be an append file command, more file commands in general actually. I worked up some functions a while back for file control:

http://forum.thegamecreators.com/?m=forum_view&t=59015&b=6

I also wrote a small tutorial on basic file control(attached to this post). Basically to append to a file, you must first make a copy of the file, then delete the original. Then use the OPEN TO WRITE command to make a new file, then have some sort of loop to read from the copy and write to the new file, and don't forget to append the data that you need. It sounds complicated, but it's not at all, the link I gave you shows some functions that do just that.

Attachments

Login to view attachments
Zerk
17
Years of Service
User Offline
Joined: 13th May 2006
Location: Orbiting Jupiter
Posted: 16th Jul 2006 22:49
Hmmm. I was hoping to be able to avoid this method but WriteStringToEnd() is what I had in mind as an ultimatum.

Thanks!

I am putting myself to the fullest possible use, which is all I think that any conscious entity can ever hope to do. ~Hal-9000
Fallout
21
Years of Service
User Offline
Joined: 1st Sep 2002
Location: Basingstoke, England
Posted: 16th Jul 2006 23:14
Just keep the file open. I literally this minute have written a logging system for claymore island.



Note, GameConfig(0).logcount is a global array. You dont need that. I just used it to add a number to each entry. Just call StartLog, call AddLog anytime you want to add a message and then close it down at the end with EndLog. If your proggy crashes before the endlog command, the file is still written and doesnt cause any problems.

CattleRustler
Retired Moderator
20
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 16th Jul 2006 23:25
DBP_NETLIB

Science, Mathematics, and Physics do not lie - only people do.
Zerk
17
Years of Service
User Offline
Joined: 13th May 2006
Location: Orbiting Jupiter
Posted: 17th Jul 2006 02:49
Quote: "
Just keep the file open.
"


Thats a good idea Fallout. But it would mean going through all my code and revamping thier file numbers. I have a function to return a free file number so I guess I should do that anyways.

@CattleRustler
Thanks! There is alot of good stuff up there but I have a thing about .NET. I try to avoid it because the end user most often cant comprehend the process of installing it... not to mention the HUGE download size and usually ends in a "Pfft! *click* <delete>".

I am putting myself to the fullest possible use, which is all I think that any conscious entity can ever hope to do. ~Hal-9000
CattleRustler
Retired Moderator
20
Years of Service
User Offline
Joined: 8th Aug 2003
Location: case modding at overclock.net
Posted: 17th Jul 2006 04:26
23 megs for framework 1.1?
framework 2.0 is common already.

suit yourself. just pointing out whats available.

cheers

Science, Mathematics, and Physics do not lie - only people do.
the_winch
21
Years of Service
User Offline
Joined: 1st Feb 2003
Location: Oxford, UK
Posted: 17th Jul 2006 04:30
Try this attached plugin. Allows you to append to files using commands similar to the dbpro file functions.

I would still change the code to keep the file open. Opening and closing a file every time you write to the log isn't very efficent. Probably won't slow the game down much but still better to avoid it.

By way of demonstration, he emitted a batlike squeak that was indeed bothersome.

Attachments

Login to view attachments

Login to post a reply

Server time is: 2024-04-26 13:36:51
Your offset time is: 2024-04-26 13:36:51