Open Text File for Writing
Verb: openTextWriter
Opens a text file for writing on it, using the path, share permission, and encoding that can change the file later.
Syntax
openTextWriter --mode(AutomationFileMode) --autoflush(Boolean) --share(AutomationFileShare) --path(String) --encoding(EncodingType) (TextFileWriter)=value
Inputs
Script | Designer | Required | AcceptedTypes | Description |
---|---|---|---|---|
--mode | Mode | Required | AutomationFileMode | Write mode option used to open the file:
|
--autoflush | Auto Flush | Required | Boolean | When enabled, makes it possible to automatically save each change within the file. |
--share | Share mode | Required | AutomationFileShare | Option that allows you to perform actions within the file while it is open for writing:
|
--path | Path | Required | Text | Full path of the text file used for writing. |
--encoding | Encoding | Required | EncodingType | Character encoding option to use when writing text file:
|
Outputs
Script | Designer | AcceptedTypes | Description |
---|---|---|---|
value | Text Writer | Text File Writer | Text file opened for writing. |
Example
The Open Text File for Writing command opens the text file and therefore the Write in Text File command writes into the file.
defVar --name filePath --type String
defVar --name textWriter --type TextFileWriter
getSpecialFolder --folder "Desktop" filePath=value
// Open or create the text file for writing and return the variable with the file open for writing.
openTextWriter --mode "OpenOrCreate" --autoflush --share "ReadWrite" --path "${filePath}\\text.txt" --encoding "Default" textWriter=value
// Write the text "IBM Robotic Process Automation" into the file.
textWrite --text "IBM Robotic Process Automation" --file ${textWriter}
Remarks
The output variable Text Writer stores the text file, which can be opened by commands such as Write in Text File, allowing only the changes selected in Share mode.
If the Auto Flush parameter is not enabled, the writing changes made to the file will only be saved when the file is closed.