Blockland Forums > Modification Help
Filewriting loopcheck and rewrite
(1/2) > >>
ThinkInvisible:
I have a clientsided database chat mod, and i need one more thing
I want to, before making the variable, scan the file for the variable being set...
I found how to scan a file elsewhere, but i can't figure out how to find the variable.

So i need to know how to:

A. Scan the file for a certain line. I worked this out, but i REALLY need to know how to write over a line.
B. If the line is found, then it will overwrite the variable on THAT LINE ONLY, nothing else.
C. If it isn't, append the new variable to the bottom of the file(I can do this)

Can someone please answer?
Syntax:
I think you can use this

--- Code: ---function whatever(%input) //Input is the name of your variable you want changed
{
//fileobjectcreated
//fileobjectopenforwrite
//tolazytodoit
while(!%file.isEOF())
{
%line = %file.readLine();
if(getSubStr(%line,0,1) $= "$")
if(getSubStr(getWord(%line,0),0,strLen(getWord(%line,0))/2) $= strLen(%input)/2)
{
%file.writeLine(%changevariabletowhatever);
break;
}
}
}

--- End code ---

I haven't tested it, but i hope the theory of this can help you, or if someone actually knows how to do it a more efficient way, correct me.
SkullCandy:

--- Quote from: Syntax on August 26, 2010, 09:19:59 PM ---I think you can use this

--- Code: ---function whatever(%input) //Input is the name of your variable you want changed
{
//fileobjectcreated
//fileobjectopenforwrite
//tolazytodoit
while(!%file.isEOF())
{
%line = %file.readLine();
if(getSubStr(%line,0,1) $= "$")
if(getSubStr(getWord(%line,0),0,strLen(getWord(%line,0))/2) $= strLen(%input)/2)
{
%file.writeLine(%changevariabletowhatever);
break;
}
}
}

--- End code ---

I haven't tested it, but i hope the theory of this can help you, or if someone actually knows how to do it a more efficient way, correct me.

--- End quote ---
I think I have a more efficient way, but I don't know if it works.
ThinkInvisible:

--- Quote from: Syntax on August 26, 2010, 09:19:59 PM ---I think you can use this

--- Code: ---function whatever(%input) //Input is the name of your variable you want changed
{
//fileobjectcreated
//fileobjectopenforwrite
//tolazytodoit
while(!%file.isEOF())
{
%line = %file.readLine();
if(getSubStr(%line,0,1) $= "$")
if(getSubStr(getWord(%line,0),0,strLen(getWord(%line,0))/2) $= strLen(%input)/2)
{
%file.writeLine(%changevariabletowhatever);
break;
}
}
}

--- End code ---

I haven't tested it, but i hope the theory of this can help you, or if someone actually knows how to do it a more efficient way, correct me.

--- End quote ---
That doesn't really work for what i need, as:
-What i REALLY needed, was how to rewrite just that line, even if it is midfile, with a new line.
EDIT : And now that i study the script more closely, wouldn't that make an infinite loop that crashes you? Because i see no incrementing command.
ThinkInvisible:
Is it even possible to do what i need done?
Navigation
Message Index
Next page

Go to full version