Raised This Month: $ Target: $400
 0% 

Delete line in file


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Obbin
Senior Member
Join Date: Mar 2005
Location: 192.168.1.3
Old 02-03-2006 , 09:18   Delete line in file
Reply With Quote #1

How to delete a line in a config?

Like this:

Quote:
Originally Posted by File.txt
1.
2.
3.
4.
then delet line 3

Quote:
Originally Posted by File.txt
1.
2.
4.
Do i have to move all lines under 3 up one line or is there any easyer way?
__________________
Sig(h)!
Obbin is offline
DaSoul
Senior Member
Join Date: Jan 2006
Old 02-03-2006 , 10:33  
Reply With Quote #2

I think you have to read the lines in you want to keep write them out...to another file and then just not write out the line you want to delete.
DaSoul is offline
Xanimos
Veteran Member
Join Date: Apr 2005
Location: Florida
Old 02-03-2006 , 12:00  
Reply With Quote #3

depends on if you care about blank lines.
Xanimos is offline
Send a message via AIM to Xanimos Send a message via MSN to Xanimos
Obbin
Senior Member
Join Date: Mar 2005
Location: 192.168.1.3
Old 02-03-2006 , 13:12  
Reply With Quote #4

Yeah i care about blank lines.

Right now i'm doing like DaSoul said (allmost):
1) Read the whole file to an array
2) Delete the file
3) Recreates the file
3) Rewrite the lines i want to keep

Any other way?

[OFFTOPIC]
Is there any function in pawn like php's StrToLowerCase
[/OFFTOPIC]
__________________
Sig(h)!
Obbin is offline
teame06
i have a hat
Join Date: Feb 2005
Location: Hat City
Old 02-03-2006 , 13:20  
Reply With Quote #5

Code:
write_file(file, "", line)


Just replace the line with a blank line. Line = the number where it located.
__________________
No private support via Instant Message
GunGame:SM Released
teame06 is offline
Send a message via AIM to teame06
Obbin
Senior Member
Join Date: Mar 2005
Location: 192.168.1.3
Old 02-03-2006 , 13:27  
Reply With Quote #6

But i dont wan't to replace it width a blank line.
Then after a while the config would be like this:

Quote:
Originally Posted by config_file.cfg
//Here are some stuff





















































//Here are some stuff
__________________
Sig(h)!
Obbin is offline
Xanimos
Veteran Member
Join Date: Apr 2005
Location: Florida
Old 02-03-2006 , 22:03  
Reply With Quote #7

Quote:
Originally Posted by obbin
[OFFTOPIC]
Is there any function in pawn like php's StrToLowerCase
[/OFFTOPIC]
Code:
strtolower ( string[] ) strtoupper ( string[] )  //just incase
Xanimos is offline
Send a message via AIM to Xanimos Send a message via MSN to Xanimos
Obbin
Senior Member
Join Date: Mar 2005
Location: 192.168.1.3
Old 02-04-2006 , 04:22  
Reply With Quote #8

Thx suecid3.

Now since there not seems to be a simple way to delete lines in files, I think I'll post a suggestion for a new function.
__________________
Sig(h)!
Obbin is offline
Xanimos
Veteran Member
Join Date: Apr 2005
Location: Florida
Old 02-04-2006 , 08:42  
Reply With Quote #9

no real easy way to do it. Someone would have to read the whole file into an array then resave it with a row missing.
Xanimos is offline
Send a message via AIM to Xanimos Send a message via MSN to Xanimos
Twilight Suzuka
bad
Join Date: Jul 2004
Location: CS lab
Old 02-04-2006 , 12:54  
Reply With Quote #10

It is possible to do this with the Stream module.

However, no matter what, there is no good way to do this.
__________________
Twilight Suzuka is offline
Send a message via AIM to Twilight Suzuka Send a message via MSN to Twilight Suzuka
Reply



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 05:57.


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