Add option in Action TXT Number of Lines to select EoL char

Post comments and suggestions for RoboTask here
Post Reply
juanlu
Posts: 46
Joined: Wed Jul 31, 2019 12:33 am

Add option in Action TXT Number of Lines to select EoL char

Post by juanlu »

Hi Oleg,

We came across a change request today where we unfortunately had to stop using the handy action "TXT Number of Lines" - because now we need to count only the EoL chars CR+LF (\r\n).

Basically you can have a csv file opened in Excel and see only one record, but if you open it in notepad you see multiple lines. This is because it's depending on the EoL (CR+LF vs only LF).

There was no way of doing it using an out-of-the-box action in RoboTask (just with point-and-click, no code). No option to select which EoL chars should be considered in the action "TXT Number of Lines" (https://robotask.com/help/index.php?txt ... _lines.htm). Also no action for searching number of occurrences of a char in a string.

So we ended up using a JS Script action (in combination with a Read Text File action), using the following extremely simple code: https://stackoverflow.com/questions/400 ... -in-string

Code: Select all

var temp = RoboTaskApp().ExpandText("{File_Content}");
var count = (temp.match(/\r\n/g) || []).length;
RoboTaskApp().SetUserVariable("Current_File_nr_of_Lines", count);
But obviously it would be much better to have an option in the action "TXT Number of Lines" instead of having to code. Would you please consider this enhancement?

Kind regards, Juanlu.
Post Reply