without using a for loop:
[codebox]
//new script!
/*something like:
FileToString(file,NewLine (true||false));
argument0: file with path (working_directory temp_directory etc);
argument1: adding a # for a new line, true or false;
*/
var _file, _contents;
_file = argument0; //storing the file in a temp var, _file
if (argument1) { //If newLine is true, then add a #
_newLine = "#";
} else { //Else, Don't

_newline = "";
}
_contents = ""; //Contents = nothing (yet

)
if (!file_exists(_file)) { //Checking if file exists, else you exit and return false

return false; //Like I said, returning an error

exit; //Exits this step, and this script
} else {
tmpFileName = file_text_open_read(_file); //storing the unread file contents in a variable
while (!file_text_eof(tmpFileName)) { //While the file hasn't ended..
_contents += file_text_read_string(tmpFileName) + string(newline); //add the string (and the newline if true) to the contents
file_text_readln(tmpFileName); //If you don't use this, you'll end up reading the first line an unlimited times

}
}
return _contents;
/*You return the contents so you could use this script like:
filecontents of file readme.txt:
--------------------------------------------------------------------------
Hello, this is my neat little example
of using
a text file to a string!
--------------------------------------------------------------------------
I'd like to read the contents of that text file: |
2 values, 2 outcomes

: |
FileToString(fileabove,true) will return: |
--------------------------------------------------------------------------
Hello, this is my neat little example#of using##a text file to a string!
--------------------------------------------------------------------------
Or |
--------------------------------------------------------------------------
Hello, this is my neat little exampleof usinga text file to a string!
--------------------------------------------------------------------------
*/[/codebox]
I know i'm beaten by him, but mine is a little more commented

Only a little though
Edited by RocketLauncher3G, 17 January 2010 - 06:24 AM.