Open Text File for Reading
Verb: openTextReader
Opens a readable text file using the path, the share permission, and the encoding that can alter the file later.
Syntax
openTextReader --share(AutomationFileShare) --path(String) --encoding(EncodingType) (TextFileReader)=value
Inputs
| Script | Designer | Required | AcceptedTypes | Description |
|---|---|---|---|---|
| --share | Share Options | Required | AutomationFileShare | Option that allows you to perform actions within the file while it is open:
|
| --path | Path | Required | Text | Full path of the text file that should be read. |
| --encoding | Encoding | Required | EncodingType | The character encoding used for reading the text file:
|
Outputs
| Script | Designer | AcceptedTypes | Description |
|---|---|---|---|
| value | Text Reader | Text File Reader | Text file opened for reading. |
Example
The Open Text File for Reading command opens the entered text file and then, the Get Text File Line command returns the contents of the first line of the file.
defVar --name textReader --type TextFileReader
defVar --name displayedText --type String
// In this excerpt, the statement finds the text file and stores it open for reading in a variable named "readerText".
// Download the following file to execute the command.
openTextReader --share "Read" --path "fileText.txt" --encoding "Default" textReader=value
textReadLine --linenumber 1 --file ${textReader} displayedText=value
logMessage --message "${displayedText}" --type "Info"
// The example displays the first line of text from the given file.
Remarks
The output variable Text Reader stores the text file that can be opened by commands such as Get Text File Line, allowing only the changes selected in the Share Options parameter.