Raised This Month: $ Target: $400
 0% 

Trying to remove the ; at the start of a line in a file..


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Greenberet
AMX Mod X Beta Tester
Join Date: Apr 2004
Location: Vienna
Old 04-26-2006 , 11:09  
Reply With Quote #3

Code:
new modulesINI[] = "addons/amxmodx/configs/modules.ini"; new tempModulesINI[] ="addons/amxmodx/configs/temp_modules.ini"; public MODULE_Enable( module_name[] ) {     new fp = fopen( modulesINI, "r" );     new data[128];     new fptemp = fopen( tempModulesINI, "w" );     while( !feof( fp ) )     {         fgets( fp, data, 63 );         server_print( "Searching %s", data );         // Module Name Found         if ( contain( data, module_name ) != -1 )         {             // Semicolon before module name found             if ( contain( data, ";" ) != -1 )             {                 // Lets go to the start of the line we're on so we can remove the ;                 fseek( fp, strlen(data), SEEK_CUR );                 // Remove the ; from the line                 replace( data, strlen(data), ";" , "" );                 server_print( "%s", data );                 new len = strlen( data );                 for ( new i = 0; i < len; i++ )                 {                     fputc( fptemp, data[i] );                     server_print( "%c:%s", data[i], data[i] );                 }                 server_print( "done" );             }         }     }     fclose( fp );     fclose( fptemp );         delete_file( modulesINI );         //we dont have an rename_file function so we have to copy the temp file again     fp = fopen( modulesINI, "w" );     fptemp = fopen( tempModulesINI, "r" );     while( !feof( fptemp ) )     {         fgets( fptemp, data, 63 );         //fputs( fptemp, data ); // we don't have this native so we have to use another method                 new len = strlen( data );         for ( new i = 0; i < len; i++ )         {             fputc( fp, data[i] );         }           }         fclose( fp );     fclose( fptemp );         //delete the tempfile     delete_file( tempModulesINI ); }
this one should work( not tested )
Greenberet is offline
Send a message via ICQ to Greenberet Send a message via MSN to Greenberet
 



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 05:09.


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