Lasso Soft Inc. > Home

[ file->openRead ]

Method

The [file->openRead] method can be called on a [file] object to open a file for reading only. If a path is already stored in the [file] object, it can be called with no parameters. It can also be called with a string specifying the path to a file. If it is called with a path to a file, that new path becomes the path for the file object, overriding any previous path.

  • Syntax
local(f) = file(...)
#f->openRead

local(f) = file
#f->openRead('/path/to/file.txt')
Examples
  • Beginner

Switching open file paths

The code below demonstrates the two different ways to call [file->openRead] and the effects on the [file] object's path.

Code

local(my_file) = file('/test.lasso')
#my_file->doWithClose => {^
    #my_file->openRead
    #my_file->path
    '<br>'
    #my_file->openRead('/index.lasso')
    #my_file->path
^}

Result

/test.lasso
/index.lasso

Recent Comments

No Comments found

Please note that periodically LassoSoft will go through the notes and may incorporate information from them into the documentation. Any submission here gives LassoSoft a non-exclusive license and will be made available in various formats to the Lasso community.

LassoSoft Inc. > Home

 

 

©LassoSoft Inc 2015 | Web Development by Treefrog Inc | PrivacyLegal terms and Shipping | Contact LassoSoft