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.


openTextWriter --mode(AutomationFileMode) --autoflush(Boolean) --share(AutomationFileShare) --path(String) --encoding(EncodingType) (TextFileWriter)=value


Script Designer Required AcceptedTypes Description
--mode Mode Required AutomationFileMode Write mode option used to open the file:
  • Append
  • Create
  • Create New
  • Open
  • Open or Create
  • Truncate
  • --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:
  • Delete
  • Inheritable
  • None
  • Read
  • Read and Write
  • Write
  • --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:
  • Automatic
  • Big Endian Unicode
  • Operating System Default
  • Unicode
  • UTF32
  • UTF7
  • UTF8
  • Outputs

    Script Designer AcceptedTypes Description
    value Text Writer Text File Writer Text file opened for writing.


    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}


    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.

    See Also

  • Binary Read Int
  • Close Binary File
  • Close Text File
  • Get Binary File Boolean
  • Get Binary File Characters
  • Get Binary File Text
  • Get Date and Time in Binary
  • Get Table from a Text File
  • Get Text File Line
  • Go to Text Reader Line
  • Move Index in Binary File
  • Open Binary File for Reading
  • Open Binary File for Writing
  • Open Text File for Reading
  • Read Binary File Decimal
  • Read Binary File Time Span
  • Read Delimited Line of Text File
  • Read Text to the End
  • Save Changes to Binary File
  • Save Changes to Text File
  • Write Boolean in Binary File
  • Write Date Time in Binary File
  • Write Decimal to Binary File
  • Write Delimited Text Line to Text File
  • Write Delimited Texts in Text File
  • Write in Text File
  • Write Integer to Binary File
  • Write Text in Binary File
  • Write Text Line to Text File
  • Write Time Span in Binary File