How to print array of string in uipath

How to print array of string in uipath

3 Likes

Hi @tgopalas,
You have to give the array variable in for each loop and print that value
refer this test.xaml (8.2 KB)

3 Likes

Hi @tgopalas,

using for each activity inside the body content use log message to print the value in the output screen.

Regards,
Arivu

3 Likes

@tgopalas
you can print the array of string in a line by seperating it with a delimeter like (comma etc)
use log message
Inside log try this
string.Join(“,”,List_Variable)

If you want to print each element in different line then use this
string.Join(System.Environment.NewLine,List_Variable)

Regards,
Mahesh

26 Likes

Thank you @Ajithkumar_P

Thank you @MAHESH1

Thank you @arivu96

Mahesh how can we find functions and syntax for each, like one you told to print on new line.

I’m unable to find these things at one place Please help

@nikhil_rao

You can just search in Google and you should get good results. Like you can search for how to output an array.

Also, you don’t necessarily need to remember everything if you just learn a few basic concepts. Like for instance, if you know by typing Array followed by a period you get a list of functions; additionally, if you know you can type String and a period you can find the functions that can be used. And just the same, if you have a variable that is an array, string, or other types, by typing a period it will list all the functions you can use.

Once you find a function that could work, by typing a Parenthesis, it will show the properties that it needs inside the parenthesis (and there different properties that can be used for some by pressing the down arrow).

See some snippets below:
image
image

So it just comes from experience and learning the things that are most useful and you use a lot, because you won’t use everything.

You can remember to join any list to a string so you can output it to a variable, Message Box, or Write Line… well, you are forming a String and joining so it’s must be String.Join() then it will show you the properties it needs by typing in the parenthesis.

I hope that helps you. I don’t think there really is a good place to find these things. But, if there is a place that does and you like the resource then you can find it by searching on Google.

Regards.

3 Likes

thanks but it becomes difficult for small small things to search, not like selenium where u can explore a lot.

How to handle empty values in array ?

Use conditional statement like “IF”, In the condition check for the length of the array if length equals zero don’t do manipulation with the array.

Sorry for the hikack.

If i wanted to do this but only get the first 10 items in the lost how would I do it?

Thanks

Mark

I’m talking about this…

string.Join(“,”,List_Variable)

Thanks

@MarkC1500

string.Join(“,”,List_Variable.AsEnumerable().Take(10).ToList)

Regards,
Mahesh

3 Likes

Exactly what I was looking for… :wink:

what is Take here ?

Worked for me …Thanks @MAHESH1 :+1:

Take is a function used to get specific number of values.