Page 1 of 1

Loop // Str Search

PostPosted: Thu Sep 08, 2016 1:41 am
by TinTin
... this should work right???... :-(

Original strings are
[Book_1]
[Book_2]
[Book_3]
etc



Loop 1 10 [pos]
StrSearch "New Book" "[Book_[pos]]" [Book_Icon]
If [Book_Icon] > 0
MessageBox "Book Found" "Yes" "OK" ""
Endif
EndLoop

Re: Loop // Str Search

PostPosted: Thu Sep 08, 2016 6:46 am
by Gaev
TinTin:

Try this code ...
Code: Select all
CreateArray [Book_] "Apple,Banana,Cherry"

Loop 0 2 [pos]
     StrSearch "Banana" "[Book_([pos])]" [Book_Icon]
     AlertBox "Search" "[Book_([pos])] ... [Book_Icon]" ""
EndLoop


Note ...

1) I used CreateArray command ... array variables will be [Book_0] to [Book_2]

2) Use ( ) to reference individual array items e.g. [Book_(1)] or [Book_([pos])]

3) Use AlertBox instead of MessageBox ... the latter is used to ...
Display a custom message box and store the selected option as a number (1 for first, 2 for second... or zero for none) in a variable.


Be aware that when you use AlertBox within an event, they are all displayed at the end of the processing of that event ... overlayed on top of each other ... so, you will see the displays in the order [Book_2], {Book_1] and [Book_0]

Re: Loop // Str Search

PostPosted: Thu Sep 08, 2016 7:26 am
by TinTin
Cheers Gaev,

I'll give this a go, nice solution.


Cheers