Author Topic: Reading a file client side ?  (Read 1624 times)

I want to read a file and echo it to the console, but whenever i do openpc("pathtofile"); it makes an infinite loop saying Line:
this is my code:
Code: [Select]
function openpc(%path){
%file = new FileObject();
%file.openForRead(%path);

while(!%file.isEoF){
$pcContent = %file.readLine();
echo("Line: "@$pcContent);
}


}
I want to do it client sidely

%file.isEOF is a method. It should be %file.isEOF().

%file.isEOF is a method. It should be %file.isEOF().
That worked, thank you very much.

For the record: A lot of features, including but not limited to file IO is engine-sided, not client-sided or server-sided. It's exactly the same no matter what.

Also, be sure to close and delete the file to avoid issues.

Also, be sure to close and delete the file to avoid issues.
What he means is

Code: [Select]
function openpc(%path){
%file = new FileObject();
%file.openForRead(%path);

while(!%file.isEoF()){
$pcContent = %file.readLine();
echo("Line: "@$pcContent);
}
%file.close();
%file.delete();
}

Also, be sure to close and delete the file to avoid issues.
Doing so prevents memory leaks.

Yea, you are not deleting the file itself, only the object that the engine uses to actually read the file.

Does anyone know any File Object tutorials? For future reference with people who're learning?

nevermind:

Resources List
A list of resources to aid you or for you to learn from.
This thread encourages members to contribute in any way they can, so don't be shy!



Resources by otto-san (10293)

File Object Tutorial
http://forum.blockland.us/index.php?topic=151078.0
« Last Edit: August 16, 2013, 10:45:10 AM by nerraD »