Raised This Month: $32 Target: $400
 8% 

Clear or delete a data file


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
StrikerM
BANNED
Join Date: Nov 2019
Old 03-08-2021 , 17:09   Clear or delete a data file
Reply With Quote #1

Hello, how the title says.

I have a point system that i want to clear it some times, i don't want to clear it manually.
I want to use something like fdelete(filename); or something like that.

I am using this system just to remove every line, but is not cleared, i just 'spaced' every line.

Code:
public TEST2(id) 
{
	Linie = 0;
	new authid[32], Line[70], Arg1[32], Arg2[32], Arg3[11], FileOpen = fopen(File, "rt" );
	get_user_authid(id, authid, 31);

	while(!feof(FileOpen)) 
	{
		Linie++;
		fgets(FileOpen, Line, 70), trim(Line), parse(Line, Arg1, 31, Arg2, 31, Arg3, 11);
		write_file(File, "", Linie);
	}
	fclose(FileOpen);
	return PLUGIN_HANDLED;
}
StrikerM is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 03-08-2021 , 17:14   Re: Clear or delete a data file
Reply With Quote #2

delete_file(File)
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
StrikerM
BANNED
Join Date: Nov 2019
Old 03-08-2021 , 17:26   Re: Clear or delete a data file
Reply With Quote #3

Quote:
Originally Posted by OciXCrom View Post
delete_file(File)
Thanks mate, but can i do something to just clear the file and not delete it ?

Last edited by StrikerM; 03-08-2021 at 17:56.
StrikerM is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 03-08-2021 , 18:55   Re: Clear or delete a data file
Reply With Quote #4

What's the difference? It will get created again as soon as you try to write in it.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
StrikerM
BANNED
Join Date: Nov 2019
Old 03-08-2021 , 19:06   Re: Clear or delete a data file
Reply With Quote #5

I just wanted to know if is a solution, but you are right too.
StrikerM is offline
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 03-08-2021 , 21:16   Re: Clear or delete a data file
Reply With Quote #6

Take a look at fopen(). Using "w" as the flag will delete the file's contents.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 03-08-2021 , 23:03   Re: Clear or delete a data file
Reply With Quote #7

Offtopic, FYI:

Instead of:
PHP Code:
while( !feof(FileOpen) ) 
You should use:
PHP Code:
while( fgets(FileOpenLine70) ) 
__________________
fysiks is offline
redivcram
Veteran Member
Join Date: Jul 2014
Location: Serbia
Old 03-09-2021 , 10:28   Re: Clear or delete a data file
Reply With Quote #8

Don't forget to use charsmax(Line) instead of hard-coding.
redivcram is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 22:06.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode