The errors (if the file not exist)
<03/12/2011 - 19:04:17>
AN ERROR HAS OCCURED [cannot open file]
<03/12/2011 - 19:04:17>
CALLSTACK
<03/12/2011 - 19:04:17> *FUNCTION [file_exists()] Scripts/Main/new.nut line [18]
<03/12/2011 - 19:04:17> *FUNCTION [onScriptLoad()] Scripts/Main/new.nut line [3]
<03/12/2011 - 19:04:17>
LOCALS
<03/12/2011 - 19:04:17> [file_path] "/Text.txt"
<03/12/2011 - 19:04:17> [this] TABLE
<03/12/2011 - 19:04:17> [this] TABLE
The code:
function onScriptLoad()
{
if(file_exists("/Text.txt"))
{
print("Yeap");
}
else if(!file_exists("/Text.txt"))
{
print("Nope");
}
return 1;
}
function file_exists(file_path)
{
local file_handle = file(file_path, "r");
if(!file_handle)
{
return false;
}
return true;
}