AddContentToLine()
From Hack Wars Wiki
The following script will add content to the end of the line provided. This is just a formatted version of overwriteLine() as made by TerribleTrioJoe. I simply edited it to not get rid of the content already there but just to add to it at the end of the line.
void addContentToLine(string file, string content, int lineNum) { if(!fileExists(file)) // if the file does not exist, create a new file containing content { writeLine(file,content); }else if(lineNum>=countLines(file)) // if lineNum is not in the file, add it to the end of the file { writeLine(file,content); }else{ string newcontent = ""; string oldcontent = readLine(file, lineNum); int totalLines = countLines(file); for(int i = 0; i < totalLines; i++) { if(i==lineNum) { newcontent += oldcontent+content; newcontent += char(10); }else{ newcontent += readLine(file,i); newcontent += char(10); } } clearFile(file); writeFile(file,newcontent); } } |
--Drizzt 11:58, 15 February 2009 (UTC)
