Raised This Month: $ Target: $400
 0% 

How to put text to the next line in file?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
[Black_Jack]
Member
Join Date: Mar 2010
Location: Novosi[Beer]sk
Old 08-15-2010 , 05:57   How to put text to the next line in file?
Reply With Quote #1

I have a cycle "for". In this cycle i need to write a text, and in next cycle, need to place text to next line. Not replace existing. I tried to format with ^n at end. Tried to fputs, fprintf, but nothing changes. help
__________________
[Black_Jack] is offline
Send a message via ICQ to [Black_Jack]
SpeeDeeR
Veteran Member
Join Date: Mar 2010
Location: Bulgaria
Old 08-15-2010 , 06:22   Re: How to put text to the next line in file?
Reply With Quote #2

if you ment what I think you ment you can put a bool to check whenever is the second/third etc. return.
SpeeDeeR is offline
[Black_Jack]
Member
Join Date: Mar 2010
Location: Novosi[Beer]sk
Old 08-15-2010 , 06:34   Re: How to put text to the next line in file?
Reply With Quote #3

Well, i'm thank abou this. Bui i dont care how to check is that next line So can someone help me.



PS I dont scripting about half year. So i'm totally forgot about operators and functions
__________________
[Black_Jack] is offline
Send a message via ICQ to [Black_Jack]
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 08-15-2010 , 07:26   Re: How to put text to the next line in file?
Reply With Quote #4

Just use write_file() and don't specify a line.
__________________
Hunter-Digital is offline
SpeeDeeR
Veteran Member
Join Date: Mar 2010
Location: Bulgaria
Old 08-15-2010 , 07:33   Re: How to put text to the next line in file?
Reply With Quote #5

You dont care ? Did you mean you dont know O.o
PHP Code:
new bool:IsSecond false //check if its the second return 
for(i=0;i<5;i++) // 4 returns 
{
if(
IsSecond)
{
fprint(smth)
IsSecond false
}
else 
// Its not the second return, its the first
{
fprint(smth else)
IsSecond true // so the next return is second

But this is example and its not usable for your script because it will return first the 'first return' than 'second return' so it will print only to lines multiple times.So if you want to use it only once modify it like you want.
SpeeDeeR is offline
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 08-15-2010 , 07:41   Re: How to put text to the next line in file?
Reply With Quote #6

Those are 5 returns and your code switches from one code to another, it doesn't stop at the second 'line' since you're setting that to false again.

And if you just want to add multiple lines with multiple different content you don't need any loop... just use fopen() and fprint() or just write_file() and it will write the data on a new line.
__________________
Hunter-Digital is offline
[Black_Jack]
Member
Join Date: Mar 2010
Location: Novosi[Beer]sk
Old 08-15-2010 , 10:50   Re: How to put text to the next line in file?
Reply With Quote #7

Problem Solved! Thanks to all!
__________________
[Black_Jack] is offline
Send a message via ICQ to [Black_Jack]
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 08-15-2010 , 17:29   Re: How to put text to the next line in file?
Reply With Quote #8

You should be able to append with the fopen(), fputs(), and fprintf() functions. I think you just need to open it with flag "a" instead of "w".
__________________
fysiks is offline
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 21:51.


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