A question about "split"

Hello,
I have a question about "split"
Could you help me?
(Sorry for my English)

I made an example


It shows
"Select list item: Attempt to get item number 2 of a list of length 1: (12345)"

I know it's because it can't find "6"
I want it tells me it can't find "6"
But the "ErrorOccurred" doesn't work

So I use an "IF" block


It works
But it's too complicated
There are too many :cry:
Is there a better way?

Thank you

Your code must be clean and protected against incorrect situations. If you can serve IF blocks, as you did it below. You can also use extensions:

How to use it? :pleading_face:


It shows
"The arguments , [(12345)], [2] are the wrong number of arguments for SelectListItem"

What is the "ID" for?
If I split the text twice, will the extension tell me which produced the error?

How to use the extension can tell @iamwsumit

I think the identifier is used to let you use the method in many places in the app. When an error occurs, the event will return an ID and you will thus know which block the error occurred in. The ID must be different for each instance of the method in the blocks. It can be any number, e.g. 0,1,2,3,4, maybe, it can also be a string, e.g. "list1"

1 Like

Yes. You're right.
I think @susi confused about it because the id param is not in the usage blocks because it was added afterwards.

No. It's not necessary. You can use the same id again but carefully as it may confuse you.

You can pass string to it.

Then you should use the contains block, which returns true or false...

Taifun

Thank you, Patryk_F :smiling_face_with_three_hearts:

Thank you, Sumit1334 :smiley:


When I split text at "3"
It shows
"45"

But when I split text at "6"
It shows
"call to 'TryCatch1$Catch' has too few arguments (1; must be 2)"

Did i miss something? :pleading_face:

How can you split a string at 6 which does not have 6 in it?

That just won't cause an error. A single-element list "12345" will be returned, which is not split.

So I want it tells me there is no "6" :pleading_face:
In real application, I split the string many times, when an error occurred, I don't know which is not exist

That's why selecting 2nd item throws error.

Check list length.
If greater than 1 then it means that particular item exists else not.

He did it as shown in the first post, but he doesn't like this solution, he wants a different one.
But I also think that the method will be the best there. You can also select it, make a procedure that will check the lists. Then it can be used in many places.

Besides, maybe it can be solved in a completely different way, we would have to know the author's intention.

What about following my previous advice then?

Taifun

I am :woman:...

OK I rewrote it!
Is it better? :crazy_face:

I have a lot to rewrite :joy:

You mean here? :pleading_face:


Or there is another way...?

Write what do you need? Do you want to search for text in a list or in a string?

string=123456789
need after "2"
→string=3456789
need after "5"
→string=6789
need before "8"
→string=67→what I need

Today one of "2","5","8" is changed (or all of them changed)
I need to know which, or I have to check many times

Try it:

use:

blocks (76)