LoadFile |
Files | |
Aptilis 1 |
LoadFile(FileName)
LoadFile will simply load the whole content of the file you specified into a variable.
The path indicated should be constructed according to your platform.
Windows way: c:\texts\accounts\year96.txt
Don't forget to double the back-slashes in Windows!
Unix way: /texts/accounts/year96.txt
Neat trick: If your script resides on a server
that's permently connected to the Internet (or an intranet)
you can use loadFile to load web pages and FTP files too!
Make sure you check this aspect by having a look at
LoadFile, in the Internet Family
LoadFile is very useful when used in conjonction with stuff to fill templates with data.
Return Value:
The whole file if everything was OK.
An empty string in case of error and the _errno variable contains more details
about the error.
Example:
The file c:\templates\test.txt contains the following:
This is a piece of text. That is the second line.
a = loadfile("c:\\templates\\test.txt") $ print(a$)Result:
This is a piece of text. That is the second line. |
See also:
saveFile.