AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   How to put text to the next line in file? (https://forums.alliedmods.net/showthread.php?t=135347)

[Black_Jack] 08-15-2010 05:57

How to put text to the next line in file?
 
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

SpeeDeeR 08-15-2010 06:22

Re: How to put text to the next line in file?
 
if you ment what I think you ment you can put a bool to check whenever is the second/third etc. return.

[Black_Jack] 08-15-2010 06:34

Re: How to put text to the next line in file?
 
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 :):)

Hunter-Digital 08-15-2010 07:26

Re: How to put text to the next line in file?
 
Just use write_file() and don't specify a line.

SpeeDeeR 08-15-2010 07:33

Re: How to put text to the next line in file?
 
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.

Hunter-Digital 08-15-2010 07:41

Re: How to put text to the next line in file?
 
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.

[Black_Jack] 08-15-2010 10:50

Re: How to put text to the next line in file?
 
Problem Solved! Thanks to all!

fysiks 08-15-2010 17:29

Re: How to put text to the next line in file?
 
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".


All times are GMT -4. The time now is 21:51.

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