Raised This Month: $51 Target: $400
 12% 

Edit file


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
CsIosefin
Senior Member
Join Date: Aug 2009
Old 09-04-2010 , 11:10   Edit file
Reply With Quote #1

Why not put in a file in another?
Code:
if(fp)
{
       fputs(fp, "One")
       fputs(fp, "Two")
       fputs(fp, "Three")
}
CsIosefin is offline
RedRobster
Veteran Member
Join Date: Apr 2010
Location: Your Closet
Old 09-04-2010 , 11:28   Re: Edit file
Reply With Quote #2

Huh?
__________________
RedRobster is offline
CsIosefin
Senior Member
Join Date: Aug 2009
Old 09-04-2010 , 20:00   Re: Edit file
Reply With Quote #3

I put in a text file to make it one under another.
CsIosefin is offline
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 09-04-2010 , 20:06   Re: Edit file
Reply With Quote #4

Make sure you use the "a" mode on fopen()

Code:
new fp = fopen("file.txt", "at") // "append" and "text"
__________________
Hunter-Digital is offline
CsIosefin
Senior Member
Join Date: Aug 2009
Old 09-05-2010 , 16:23   Re: Edit file
Reply With Quote #5

Code:
        new configsdir[32], file[32];
        get_configsdir(configsdir, charsmax(configsdir))
        format(file, charsmax(file), "%s/maps.ini", configsdir)

        
        if (file_exists(file))
            delete_file(file);

        new fp = fopen(file, "at");

        if(fp)
        {
            fputs(fp, "1")
            fputs(fp, "2")
        }
        
        fclose(fp);
What is not well, I do not show one in another?
CsIosefin is offline
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 09-05-2010 , 18:52   Re: Edit file
Reply With Quote #6

Is "12" written in the file ? Then it's working fine.
If you want to add a new line just specify that using ^n

Code:
fputs(fp, "line one^nline two^nline three... etc")
__________________
Hunter-Digital is offline
CsIosefin
Senior Member
Join Date: Aug 2009
Old 09-05-2010 , 19:27   Re: Edit file
Reply With Quote #7

Oh ... I did not know that ^n I can use it to file ...
Thanks Hunter-Digital
CsIosefin is offline
CsIosefin
Senior Member
Join Date: Aug 2009
Old 09-11-2010 , 20:51   Re: Edit file
Reply With Quote #8

One problem I did so:
Code:
fputs(fp,"awp_bycastor^n35hp_2^naim_ak_colt^naim_crazyjump^naim_map_usp^nawp_india^ncs_deagle5^ncs_mansion^nde_dust2_long^nde_dust2x2^nde_plant^nfy_aztec_world^nfy_buzzkill^nfy_dinoiceworld^nfy_gamesfan^nfy_snow^nfy_snow_deluxe^nfy_snow_orange^nmini_dust2")
On Windows I see this:
Code:
35hp_2
aim_ak_colt
aim_crazyjump
aim_map_usp
awp_india
cs_deagle5
cs_mansion
de_dust2_long
de_dust2x2
de_plant
fy_aztec_world
fy_buzzkill
fy_dinoiceworld
fy_gamesfan
fy_snow
fy_snow_deluxe
fy_snow_orange
mini_dust2
When you climb on host (linux) is this:
[IMG]http://img834.**************/img834/1051/39018415.png[/IMG]
CsIosefin is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 09-11-2010 , 23:40   Re: Edit file
Reply With Quote #9

It's the same thing.
Those [] chars are new line characters.
View the file in a different text editor (notepad++, textpad, etc.) and you will see it properly.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 09-12-2010 , 00:25   Re: Edit file
Reply With Quote #10

I don't use linux, but see if ^r^n works instead of just ^n.
__________________
Bugsy is online now
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 11:30.


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