Question about sequence to create conditionnal phrase etc

Good Morning Wonderfull people,
I am new with programming and RPA.
Just a short question , just to understand how it is the syntaxis to create a conditionnal or any other phrase:
This is my context:
I have a variable1 = Surname and i want to create a conditionnal phrase.
i would like to understand how we composed that phrase because i have the possibility to make two forms of conditionnal :
1.- Surname.Equals.CompareTo or
image

2.- Surname.CompareTo.Equals
image

In general is just an exemple:
I would really appreciated if you could help me to understand is there any formula, sequence or syntaxis to respect when we want create a conditionnal phrase using a Variable and then add a a point , and then another point, because i see that we have modules that repeats.

Thanks
Richch

@Ricchch
Try like this
Surname.Equal(“your name”)

Surname.Contains(“your name”)

1 Like

@Ricchch

For ease UiPath provides an easy option as well to understand better…you can click on the below symbol and you would be able to edit the conditions in a interactive screen

Directly you can give like this
like if you want to check if surname contains xyz then surname.Contains("xyz")
for exact match use surname.Equals("xyz")

cheers

1 Like

hi @Ricchch

fullName= “Daniel Ricardo”
surName=“Ricardo”
So, you want to compare Surname with some string:
you can do it like: fullName.Equals(surName) will return you false

or if you wanna check for a substring: fullName.contains(surName) will return you true.

Thanks
Happy Automation! :smiley:

1 Like

@Ricchch
To avoid case sensitive issue you can try like this as well

surname.ToString.ToUpper.Equal (“YOUR NAME”)
surname.ToString.ToLower.Equal(“your name”)

Same in contains case.

1 Like

Thank you very much @Anil_G , @adiijaiin , @raja.arslankhan
It helped me to discover the use of conditional builder… i will keep in mind that device.
i have another question if you don’t mind. (the forum helped me to build a robot but i would like to understand the logic behind this phrase: when a variable is mail

(mail.Attachments.Any(Function(x) x.Name.ToLower.Contains(“.xlsx” ))

this phrase works but i dont understand the formula or sequence and the logic to create other conditions in the futur.

I would really appreciated if you could point me where to learn or understand that…
Thanks

@Ricchch:

The differences between “Equal,” “Contains,” and “CompareTo” in string operations depend on the programming language or framework you’re working with. However, I can provide you with a general overview of these operations.

  1. Equal: The “Equal” operation compares two strings to determine if they have the same sequence of characters. It typically returns a Boolean value indicating whether the strings are equal or not. In most programming languages, this operation performs a case-sensitive comparison, meaning that the strings must have the same characters and the same casing (e.g., “hello” and “Hello” would be considered different strings).
  2. Contains: The “Contains” operation checks whether a string contains a specified substring within it. It returns a Boolean value indicating whether the substring is found within the original string. The comparison may or may not be case-sensitive, depending on the programming language or specific implementation.
  3. CompareTo: The “CompareTo” operation compares two strings to determine their relative order in lexicographic (dictionary) sorting. It returns an integer value that indicates the relationship between the two strings. Typically, it returns a negative value if the first string is less than the second, zero if they are equal, and a positive value if the first string is greater. The specific numeric values can vary depending on the language or framework.
1 Like

@Ricchch

The code snippet you provided is written in Visual Basic .NET and is using the LINQ (Language Integrated Query) syntax. Let’s break it down:

  1. mail.Attachments: This refers to a collection of attachments associated with an email or message.
  2. .Any(): This is a LINQ extension method that checks if any element in a collection satisfies a specified condition. It takes a lambda expression as an argument and returns a Boolean value indicating whether any element matches the condition.
  3. Function(x) x.Name.ToLower.Contains(".xlsx"): This is the lambda expression passed to the .Any() method. It specifies the condition to be checked for each attachment in the mail.Attachments collection.
  • Function(x) is a lambda function parameter that represents each element in the collection (attachment) being evaluated.
  • x.Name refers to the name of the attachment.
  • .ToLower() is a method used to convert the attachment name to lowercase. This is done to perform a case-insensitive comparison.
  • .Contains(".xlsx") checks if the attachment name contains the substring “.xlsx”. The Contains() method returns a Boolean value indicating whether the specified substring is found within the attachment name.

Overall, this code snippet checks if any attachment in the mail.Attachments collection has a name that contains the substring “.xlsx” (case-insensitive comparison). It will return True if at least one attachment satisfies this condition, and False otherwise.

1 Like

@Ricchch hopefully now it is clear for you.
If yes please mark it as a solution so others can get help from it.

Thanks all of you guys @raja.arslankhan , @adiijaiin , @Anil_G for your comments,
Very much appreciated…

i was wondering how i compose a sequence:

variable + method + properties + class + namespace + constants + etc?

is that the correct order?
Thank you so much… for your help…

Ricchch

the order is correct but if you use sub/functions then the order could recur.

1 Like

@Ricchch

Can you explain what you mean by this?

Cheers

@Ricchch

These are the linq queries and array level functions that are available…

(mail.Attachments.Any(Function(x) x.Name.ToLower.Contains(“.xlsx” ))

What you are checking is if in mail attachments …any of the mail attachment name contains .xlsx or no

The function you write inside is a lambda function means a in line function that will work on eqch item of the provided array which is mail.Attachments

Hope this helps

Cheers

1 Like

@Ricchch
Here check some examples regrading linq queries:

Hi @Anil_G

image

I am refering to what the graphic shows me in UiPath…
Thanks ,

@Ricchch
One more:

@Ricchch

Those are the methods and properties and variables that you have created or by default availbale in your xaml…you can access all of them…

The namespaces and methods are displayed based on the imports you use in the inports panel at bottom

Similar works for arguments and variables as well

Any package or import that you add will add more methods and fucntions to the inteface

Cheers

1 Like

Thanks to all of you guys @raja.arslankhan @adiijaiin @Anil_G
Much more appreciated for all your comments it helped me not only to know more but also to figure it out what i must check (Linq queries)

Thanks
Richch

1 Like

@Ricchch welcome. It was nice question and here discussion gone long which is really helpful others too. We are always there for help.

1 Like

@Ricchch

[HowTo] LINQ (VB.Net) Learning Catalogue - Help / Something Else - UiPath Community Forum

and for prototyping / learning
Understanding the 6 Debugging Panels of UiPath in the easiest way possible! - News / Tutorials - UiPath Community Forum

2 Likes