LassoScript Utility
Basics Browse Detail


Tag Link [File_ReadLine] Category File
Type Substitution Source Available No
Support Preferred Version 3.0
Change Unchanged Data Source Any
Output Type Bytes Security Tag, File
Implementation LCAPI Sets Lasso 8.5, Lasso 8.0, Lasso 7.0, Lasso 6.0, Lasso 5.0, Lasso 3.x


[File_ReadLine] reads a single line from a file. Accepts two parameters, the name of the file to be read and -FileLineNumber specifying which line of the file to read.

An optional keyword/value parameter -FileEndOfLine specifies what character represents the end of lines within the file. It is important to use the same end of line character that was used when the file was created. The following are the defaults for platforms which Lasso has supported.
- Mac OS X: '\n'
- Windows: '\r\n'
- Mac OS 9 or Earlier: '\r'

The file tags are protected by four different permissions. The user must have permission for all of the following in order to use this tag:
- Permission to use the tag itself.
- Permission to perform the file operation.
- Permission to work in the directory which contains the files.
- The filename extensions of the files which are being worked with must be allowed in Lasso Administration.


[File_ReadLineFile Name,
  -FileLineNumber=Line Number]

[File_ReadLineFile Name
  -FileLineNumber=Line Number
  -FileEndOfLine=End of Line Character]


Required Parameters
File Name The name of the file to be read.
-FileLineNumber The line which should be read from the file.
Optional Parameters
-FileEndOfLine The delimiter to be used to determine the end of each line. Defaults to carriage return.


To read a line from a file:

Use the [File_ReadLine] tag. The following example reads the first line from a file named myfile.txt from the root of the Web serving folder.

    Variable: 'theLine' = (File_ReadLine:  '/myfile.txt', -FileLineNumber=1);
    Output: (File_CurrentError: -ErrorCode) + ': ' + (File_CurrentError);

0: No Error