How do I emptye file?

I have this code to write information to my file:

[php]if ($newmessage ne ‘’)
{
print NEW $newmessage;
print $newmessage;
if ($chatLogging) {
my $now_string = gmtime;
if (open(CHATLOG, “>>$chatpath/$logFileName”)) {
print CHATLOG $nowtimestring .’ ’ . ‘’ . $formdata{‘cname’} . ‘:’ . ‘’ .$ColoredMessage . ‘
’ ."\n";
close(CHATLOG);
}
[/php]

This code writes allways new line so eventually some day I have huge file.
What should I do to empty file before writing so that there is always only one line in the file???

Kari

Can you not write some code that checks the file_size(the file) if its bigger than your value then rename it and make a new file ?

."\n"; that’s your new line. with the
in there, the \n is redundant. take it out and your new line will disappear.

Sorry I must have miss read your post the first time in what you wanted.
I think you need to find the function for the chat, so that you can change how it writes to the file.

What I think you want is just to have the last chat message typed not all the messages in the file.

Hi all

I just figure it out myself :slight_smile:

I simply delete file and then write so there is always only one (the last) in that file …

Kari

Sponsor our Newsletter | Privacy Policy | Terms of Service