Win an Ipad
  Developer   Documents   File stream

File stream

This article explains basic file operations in Moscrif.

File

Stream.openFile opens the specified file as file-name parameter and associates it with a stream that is used in next file operation by the Stream object which has its pointer returned.
Mode parameter defines which operation is allowed on the stream.

r Read only
w Write only
a Append to a file
r+ Read and write in a file
w+ Create new and write in a file
a+ Read and append to a file


Example of how to open and read only from sample-data.mso file in Moscrif:

var mso = "app://sample-data.mso"; //chcek if file exists
if (!System.isFile(mso)) {
    var msg = String.printf("Cannot find %s!", mso);
       System.messageBox(msg);
       throw msg;
} //open file stream
var f = Stream.openFile(mso, "r8");
if (!f)    throw String.printf("Cannot load %s!", mso); //parse retrived content  
this.data = parseData(f); //close stream
f.close();

 Files and Databases   File stream   XML Scanner 
Write a Comment (0)
Subject
 
Comment