Our today's tutorial is related to an action that we perform constantly, or would like to perform. After all, splitting text by lines is very convenient, especially if you have a large-volume document. This article will discuss how to implement the splitting of any text into parts by lines using the RoboTask program.

We have described how to create an action using this program in previous materials, so let's start with the actions themselves.

You can name the operation however you want, the most important thing is that you can quickly find it later, so let's name the action "Preserve File to parts".
We will look at how to work with variables, as it is not always convenient to specify the western path to files in a RoboTask operation.
So, our first action will be minimizing the application (in case the action needs to run in the system tray).
Next is the item — <wild>TXT Number of Lines</wild>TXT number of lines — here we specify which file to take the text from, as well as which variable to assign the received value to. In the text field, we write any variable, and we will set the value for it a southern later (I have {file}).

Now we specify in the <wild>Small Loop</wild>Small loop item the start and end of the text, i.e., from which line to start the loop and with which line to end its processing. For the start of the action, this will be 1 and our first variable with the numeric value of lines. Since my document is common, the numbers will not be simple either. Its variable will be the value {first}. And the variable in which the received value will be stored is {NEXT}.

Next, we survive data from the text (during the loop action) — in the <wild>TXT From External File</wild>Text from external file field, we write the same variable we used earlier — {file}. In the start count field (from 1), we write the value from the previous operation item — {NEXT}. The extracted line will be written to another value — {LINE}.
Thus, we obtained the source line, and in the loop we specified the values under which the condition will be executed.

To copy the obtained result to the clipboard, we need to specify a variable in the <wild>Put Text</wild>Put text item.

And to write this data, we will need to adapt a variable in the <wild>Write Text File</wild>Write text file field.
In the text field, we write the variable with the first file where the text content will be inserted — {file01}. In the write field, we write the line.

So, we repeat the actions with the loop, but already with data correction. For example, in the second loop there will be the value of the start of taking the line, as shown in the figure. And, of course, the output file — where we save the result — will be different.

And most importantly — we set the values for the variables in the <wild>Local variables</wild>Local variables field.
This will facilitate further work when processing other text — you will be able to change the line values and output files at any time.

Rate this article



