You can use this function:
Code:
FileContainsString( const szFilename[ ], const szString[ ], bool:bCaseSensitive=false ) {
new iFile = fopen( szFilename, "rt" );
if( !iFile ) {
return -1;
}
new szData[ 1024 ], iLine;
while( !feof( iFile ) ) {
fgets( iFile, szData, 1023 );
if( bCaseSensitive ? ( contain( szData, szString ) != -1 ) : ( containi( szData, szString ) != -1 ) ) {
fclose( iFile );
return iLine;
}
iLine++;
}
fclose( iFile );
return -1;
}
Then do code like this:
Code:
new iLine = FileContainsString( "myfile.txt", "some string" );
if( iLine >= 0 ) {
ReplaceLineByNumber( "myfile.txt", iLine, "replaced string" );
}
__________________