AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [Solved] Set text from a file in other. (https://forums.alliedmods.net/showthread.php?t=167865)

Fedde 09-21-2011 06:55

[Solved] Set text from a file in other.
 
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?

Arkshine 09-21-2011 07:16

Re: Set text from a file in other.
 
without getting the data

why ?

Fedde 09-21-2011 07:31

Re: Set text from a file in other.
 
Quote:

Originally Posted by Arkshine (Post 1559962)
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); }

jimaway 09-21-2011 07:34

Re: Set text from a file in other.
 
Quote:

formatex - Same as format(), except does not perform a "copy back" check.

Fedde 09-21-2011 07:53

Re: Set text from a file in other.
 
Quote:

Originally Posted by jimaway (Post 1559973)
Quote:

formatex - Same as format(), except does not perform a "copy back" check.

Does the same.

Arkshine 09-21-2011 07:54

Re: Set text from a file in other.
 
https://forums.alliedmods.net/showthread.php?t=130243

Fedde 09-21-2011 08:13

Re: Set text from a file in other.
 
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.

Arkshine 09-21-2011 08:17

Re: Set text from a file in other.
 
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.

Fedde 09-21-2011 08:35

Re: Set text from a file in other.
 
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); }

jimaway 09-21-2011 08:36

Re: Set text from a file in other.
 
maby your function gets called lot of times?


All times are GMT -4. The time now is 19:45.

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