StrSearch & CreateArray errors - Forum

Forum Navigation
You need to log in to create posts and topics.

StrSearch & CreateArray errors

Hi..

In online help as you see in the photo in explanation of StrSearch it says that it returns 0 when nothing is found which is wrong. It rerurns -1. Please update those information.

In createArray in description it says that you can use commas or line breaks, i have test it with commas and it does not work. It replace the commas with , and after that the app is not loads in web broswer. Any solution in that ?

Uploaded files:
  • You need to login to have access to uploads.

Hi @smartmedia, both commands were added by Dave and I have not touched them. I will check them and let you know whats going on.
Thank you!

smartmedia has reacted to this post.
smartmedia

@smartmedia, I think the problem comes from the way the commas are replaced from the wizard window.
If you use the wizard window just be sure to separate items by a carriage return. I will update the documentation so this is more clear.
This works perfectly:

CreateArray [myArray1] "one,two,three,four,five"
CreateArray [myArray2] 1,2,3,4,5
Consolelog [myArray1]
Consolelog [myArray2]

You can also use this:

SetVar [myvar] "one,two,three,four,five"
StrParse "[myvar]" "," [myArray]
Consolelog [myArray]

This way you can use any character as an item separator, not only commas.
Regards.

Vadim and smartmedia have reacted to this post.
Vadimsmartmedia

Hi @luishp

I test this

CreateArray [SearchArray] [ProSearchResultProID]
ArraySearch [SearchArray] "[ProId]" [ArrayResult]
If [ArrayResult] == "-1"
SetVar [ProSearchResultProID] "[ProSearchResultProID],[ProId]"
else
AlertBox "Ενημέρωση" "Έχετε ήδη πάρει τα στοιχεία επικοινωνίας" ""
endif

The [ProSearchResultProID] has already this values (10,30,42) and when i run the code i get in console that the variable is not defined and i don't get any result in [ArrayResult]

Uploaded files:
  • You need to login to have access to uploads.

@smartmedia please attach a complete sample app showing the isolated problem and I will check it.
Thank you!

smartmedia has reacted to this post.
smartmedia

@luishp

I Solved,  in the CreateArray [SearchArray] [ProSearchResultProID] he wanted quotes in "[ProSearchResultProID]"

Is a little bit mesh with those quotes on every command, by definition the program is not putting them, the same goes to setvar, he treats everything like numeric.

Again, thanks for your time and quick response.

 

 

luishp has reacted to this post.
luishp

@smartmedia note that most wizard windows allow selecting among numeric or string values.

Uploaded files:
  • You need to login to have access to uploads.

@luishp

I thrilled before and i thought i solved but no. if i put the quotes in  "[ProSearchResultProID]" i keep receive -1 as result.

The same happens if i try to add item in array. I created a demo app.

Uploaded files:
  • You need to login to have access to uploads.

@smartmedia, please try this instead:

SetVar [itemsInArray] "12,18,22,33,20"
StrParse "[itemsInArray]" "," [SearchArray]
ArraySearch [SearchArray] "18" [ArrayResult]
ArrayAddItem [SearchArray] 8
Consolelog [SearchArray]

I think CreateArray can't be filled with content from a variable. It's just for manually entered data.
Regards.

smartmedia has reacted to this post.
smartmedia

@luishp

Thats very bad news, is not useful for me, i need the array to take some data from my database. what is the purpose to take only hardcore data then ?

I could use StrSearch but he cant tell the difference between 12 and 120 in a string.

I check your solusion with the stringparse.

Thanks again.

Thats very bad news, is not useful for me, i need the array to take some data from my database.

@smartmedia not so bad, you have many alternatives.

what is the purpose to take only hardcore data then ?

Not sure, I didn't create this command.

I could use StrSearch but he cant tell the difference between 12 and 120 in a string.

Please use StrParse or JSON data from your database instead.

Let me know if you need additional information.

smartmedia has reacted to this post.
smartmedia

@luishp

The solution with the string parse and search array have worked and i get the right results. Well done mate.

luishp has reacted to this post.
luishp