Objective
The objective of this How-To guide is to assist the users in reading and writing a text file using OpenBots Studio. Most processes require access to different text files from across the system to perform separate and unique operations. OpenBots Studio makes this simple with the use of the Read Text File and Write Text File commands.
Walkthrough
The following are the steps involved in implementing basic Text File commands. It is a procedure that involves click level operations from the Text Files command list. This guide will require two text files to be created beforehand. It does not matter what these text files contain as long as they contain some information. Place these files within the project folder.
Step 1: Text files, unlike Excel commands, do not need an instance name simply because text files are simple documents that can, unsurprisingly, only store text. This means that there aren’t very many commands for text files to use. The first Text File command that will be used is the Write/Create Text File command. This command can be used to either write to an existing file or create and then write to a new text file.
  • Select the Write/Create Text File command.
  • Enter the file path for a text file. (If the file specified in the Text File Path does not exist, then this command will create it with the name specified in the field itself. If it does already exist, then it will simply write to the file. In this guide, the file specified file does not exist and will be created by this command.)
  • In the Text field, write a message that indicates that this file was just created.
  • In the Overwrite Option field, choose either “Append” or “Overwrite”. At this point, it does not matter which option is chosen. (The difference between the options is that “Append” will add the specified text to the end of the last line in the text file. This will NOT create a new line. The “Overwrite” option deletes everything in the file and writes the specified text on the first line.)
  • Click OK.
Step 2: Text files also possess a command that allows for the extraction of text from within the text file itself and store that text in a variable that can be used by other commands (like Excel and Word commands). Those other commands can be used to edit the text itself by changing things like font size, color, font style, etc. However, for this guide, text will be extracted from two existing text files and placed within two separate variables.
  • Select the Read Text File command.
  • In the File Path field, enter the file path for an existing text file.
  • In the Output Text Variable field, enter the name of the variable that will be used to store the first set of text that will be extracted from this opened text file. This guide used the name {vTextRead1}. (Don’t forget the curly brackets around the variables!)
  • Click OK.
Step 3: Now extract the text from the second text file and store it in another separate variable.
  • Select the Read Text File command.
  • In the File Path field, enter the file path for an existing text file.
  • In the Output Text Variable field, enter the name of the variable that will be used to store the first set of text that will be extracted from this opened text file. This guide used the name {vTextRead2}. (Don’t forget the curly brackets around the variables!)
  • Click OK.
Step 4: After storing the text from the files in the different variables, the text within those variables can now be used by other commands! In this guide, the text extracted will be placed within the file created in Step 1 using the exact same command that was used in that step.
  • Select the Write/Create Text File command.
  • Enter the file path for the text file created earlier.
  • In the Text field, enter the first variable that was gathered in Step 2. Before writing the variable, type [crLF] (the brackets and capitalization is important). Typing this will cause the text to be placed on a new line. This prevents the placed text from combining with pre-existing text in the document and makes the file more readable.
  • In the Overwrite Option field, choose either “Append”. “Append” is chosen because the text needs to be added to the text file. It doesn’t need to be overwritten.
  • Click OK.
Step 5: Repeat Step 4 and place the second variable created in Step 3 into the text file. This will mark the end of the guide. Screenshots can be seen below.
  • Select the Write/Create Text File command.
  • Enter the file path for the text file created earlier.
  • In the Text field, enter the second variable that was gathered in Step 3. Before writing the variable, type [crLF] (the brackets and capitalization is important). Typing this will cause the text to be placed on a new line. This prevents the placed text from combining with pre-existing text in the document and makes the file more readable.
  • In the Overwrite Option field, choose either “Append”. “Append” is chosen because the text needs to be added to the text file. It doesn’t need to be overwritten.
  • Click OK.
Note: This next screenshot displays the Created File. It displays all of the different items that were added to the file.

All the commands in this guide can be utilized alongside many of the other commands that will be discussed in later guides to perform several operations. Below is a snapshot of the process discussed in the guide.

Commands utilized for the above concepts (read and write in a text file in OpenBots Studio) are as follows:

Text File Commands: Read Text File, Write Text File

Newsletter Bot

Lets stay in touch!

Join our weekly newsletter and follow us on social media.

Contact Sales
Call Our Experts!