LUALoriotPro WEB site

LoriotPro scripting documentation
Extensions for LUA language

Table of contents Search function

Print the current page Mail this  link UTUBE Channel version française

lp.Fopen

LoriotPro has extended the LUA sripting language by providing its own LUA libraries. The new functions provided are dedicated to the creation of monitoring and SNMP automation application.

Syntax

file = lp.Fopen('filename','wt');

Description

Open a file the same way that the C ANSI function fopen.

Parameters

file             A reference to a file (handle) obtained with lp.Fopen.

Warning  ! If you want to use the \ character in the path ypu should use the \\ instead. The \ character is use for escape sequence only in LUA.

The function support only the text mode

‘rt’           Open the file in read only mode. The file pointeur is at the beginning of the file.  

‘wt’          Open the file in write mode. If the file doesn't exist, it creates it. If the file exist it is cleared and the stream pointeur it set at the beginning. 

‘at’           Open the file in write append mode. If the file doesn't exist, it creates it. If the file exist it is not cleared and the stream pointeur it set at the end. 

 

Return Values

file          A reference (handle) on the opened file.

Return nil if an error occurs

Example

fp=lp.Fopen("c:\\test1.txt","wt");
if fp then
lp.Fprintf(fp,"hello word of file","\n");
lp.Fprintf(fp,"hello word of file","\n");
lp.Fprintf(fp,"hello word of file","\n");
lp.Fprintf(fp,"hello word of file","\n");
lp.Fclose(fp);
 
fp=lp.Fopen("c:/test1.txt","rt");
if fp then
      while 1 do
            line=lp.Fgets(fp);
            if line==nil then break end
 
      lp.Print(line);
      end
lp.Fclose(fp);
end

end

Fopen

 


www.loriotpro.com