Raised This Month: $ Target: $400
 0% 

[Solved] Set text from a file in other.


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Fedde
BANNED
Join Date: Sep 2011
Old 09-21-2011 , 06:55   [Solved] Set text from a file in other.
Reply With Quote #1

I need to set the text from the [A] file to the [B] file.
Somebody knows some cmd to do it,without getting the data from [A] file and writing to [B] file?
Fedde is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 09-21-2011 , 07:16   Re: Set text from a file in other.
Reply With Quote #2

without getting the data

why ?
__________________
Arkshine is offline
Fedde
BANNED
Join Date: Sep 2011
Old 09-21-2011 , 07:31   Re: Set text from a file in other.
Reply With Quote #3

Quote:
Originally Posted by Arkshine View Post
without getting the data

why ?
I made this and when I set the data to the other file the data is copied two times.
Code:
public cmdFloatTask() {     new Path[256];     get_configsdir(Path,charsmax(Path));     formatex(Path,charsmax(Path),"%s/demos.txt",Path);         new File[256];     get_configsdir(File,charsmax(File));     formatex(File,charsmax(File),"%s/records.txt",File);         new Data[1024];     new f = fopen(Path,"rt");         while(!feof(f))     {         fgets(f,Data,charsmax(Data));         write_file(File,Data,-1);     }     fclose(f); }
Fedde is offline
jimaway
Heeeere's Jimmy!
Join Date: Jan 2009
Location: Estonia
Old 09-21-2011 , 07:34   Re: Set text from a file in other.
Reply With Quote #4

Quote:
formatex - Same as format(), except does not perform a "copy back" check.
jimaway is offline
Fedde
BANNED
Join Date: Sep 2011
Old 09-21-2011 , 07:53   Re: Set text from a file in other.
Reply With Quote #5

Quote:
Originally Posted by jimaway View Post
Quote:
formatex - Same as format(), except does not perform a "copy back" check.
Does the same.
Fedde is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 09-21-2011 , 07:54   Re: Set text from a file in other.
Reply With Quote #6

https://forums.alliedmods.net/showthread.php?t=130243
__________________
Arkshine is offline
Fedde
BANNED
Join Date: Sep 2011
Old 09-21-2011 , 08:13   Re: Set text from a file in other.
Reply With Quote #7

But that copy the file into other,but I need to set the data from file A to data from file B..B File already has some text inside.
Fedde is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 09-21-2011 , 08:17   Re: Set text from a file in other.
Reply With Quote #8

The method is more or less the same (opening 2 files, getting/setting, closing both), you just need to use fgets/fputs and opening the second file with "a+" to append datas.
__________________

Last edited by Arkshine; 09-21-2011 at 08:21.
Arkshine is offline
Fedde
BANNED
Join Date: Sep 2011
Old 09-21-2011 , 08:35   Re: Set text from a file in other.
Reply With Quote #9

Yes I tried that method,but when I test it,the A file gets copied a lot of times.

Code:
public cmdFloatTask() {     new Path[256];     get_configsdir(Path,charsmax(Path));     format(Path,charsmax(Path),"%s/demos.txt",Path);         new File[256];      get_configsdir(File,charsmax(File));     format(File,charsmax(File),"%s/demoz.txt",File);         new Data[1024];         new f = fopen(Path,"rt");     new ff = fopen(File,"at");         while(!feof(f) && !feof(ff))     {         fgets(f,Data,charsmax(Data));         fputs(ff,Data);     }     fclose(f);     fclose(ff); }
Fedde is offline
jimaway
Heeeere's Jimmy!
Join Date: Jan 2009
Location: Estonia
Old 09-21-2011 , 08:36   Re: Set text from a file in other.
Reply With Quote #10

maby your function gets called lot of times?
jimaway 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 19:45.


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