The 'Pawn Language' Forum

An embedded scripting language

 

Reply To This Topic    Back To Forum Index
 
ghost
Posted On 2009-12-21 10:48 -- Subject: [HELP!PLZ~]Replace/Update .ini File Line Function

Hi Folks,

I have a problem:

Is there a small function out there somewhere which would replace a line from a .ini file with a new line? (Also: Trying NOT to mix it up either, it must stay orangized...)

Example being:

FROM:
[player]
Health=15
Armour=65
Money=11000

TO:
[player]
Health=15
Armour=30
Money=11000

I know about someone's fdeleteline function, but wasn't able to find something for replacing. Search came up with something called SFScan or something, but I don't think that's what I'm looking for...

I would need that spefic function so it won't disturb Health or Money, just affect ONLY Armour... Maybe I should've looked at that fdeleteline & try to figure out how to convert it to replace a line, but in that area of scripting I know close to nothing still, I'll post it in luck of someone else knowing though...

THX in advance! :D

fdeleteline function Code:

public fdeleteline(filename[], line[]){
if(fexist(filename)){
new temp[256];
new File:fhandle = fopen(filename,io_read);
fread(fhandle,temp,sizeof(temp),false);
if(strfind(temp,line,true)==-1){return 0;}
else{
fclose(fhandle);
fremove(filename);
for(new i=0;i<strlen(temp);i++){
new templine[256];
strmid(templine,temp,i,i+strlen(line));
if(equal(templine,line,true)){
strdel(temp,i,i+strlen(line));
fcreate(filename);
fhandle = fopen(filename,io_write);
fwrite(fhandle,temp);
fclose(fhandle);
return 1;
}
}
}
}
return 0;
}




You Are On Page: 1/1 <<   <   1   >   >>




- BiTBOARD version 2.5 by the BiTSHiFTERS SDC -