Blockland Forums > Modification Help
Filewriting loopcheck and rewrite
<< < (2/2)
Chrono:
export("$variable with *s for wildcards", "path", 0);
Ephialtes:

--- 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 is entirely wrong and will not work, don't bother posting if you don't know how to do something - it'll just confuse people trying to learn.


--- Quote from: ThinkInvisible on August 26, 2010, 11:54:32 PM ---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.

--- End quote ---

::readLine() moves the file pointer of the file object, and ::isEOF() checks whether the pointer has reached the end of the file.

Regardless, you shouldn't be re-writing an entirely new file each time someone makes a change in this database - file handling is a lot of overhead. You should be keeping most/all of the db in memory and saving it to a flatfile db at intervals.
ThinkInvisible:
Got some major help from a friend, apparently i can just use export...
MegaScientifical:

--- Quote from: ThinkInvisible on August 27, 2010, 03:17:57 PM ---Got some major help from a friend, apparently i can just use export...

--- End quote ---

Quick note: Careful not to accidentally put in code to export into a .zip. It causes annoying errors you can't easily fix, only patch, at least on XP.
Navigation
Message Index
Previous page

Go to full version