SearchString Issue

Questions about using NeoBook's scripting language

Moderator: Neosoft Support

Locked
User avatar
Dudus
Posts: 120
Joined: Wed Sep 07, 2005 12:15 pm
Location: Hungary, Budapest

SearchString Issue

Post by Dudus »

Hi all,

will you able to help me in this case?

I have a ListBox3 wich conatins this lines:
Car Dog House John
Car Dog House Gregor
Car Dog House Thomas

and i would like to show the result in a[dispaly] variable if pick the name of the person from a combobox1, I try to do somethig like this but it wont work:

SetVar "[display]" ""
ListBoxSize "ListBox3" "[Count]"
Loop "1" "[Count]" "[N]"
ListBoxGetItem "[ListBox3]" "[N]" "[Item]"
SearchStr "[combobox1]" "[Item]" "[Pos]" ""
If "[Pos]" "=" "1"
SetVar "[display]" "[display][item][#13]"
Endif
EndLoop

Where is the problem? Because now there is 0 result.
Thank you!
D
User avatar
Gaev
Posts: 3782
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada
Contact:

Re: SearchString Issue

Post by Gaev »

Dudus:

What are the values in [combobox1] ?

a) If the values are an exact match e.g. ...

Car Dog House John
Car Dog House Gregor
Car Dog House Thomas

... then the code should work ... you can try this code and post the results of the AlertBox commands ...

Code: Select all

SetVar "[display]" ""
ListBoxSize "ListBox3" "[Count]"
AlertBox "Trace1" "combobox1=[combobox1],Count=[Count]"

Loop "1" "[Count]" "[N]"
   ListBoxGetItem "[ListBox3]" "[N]" "[Item]"
   SearchStr "[combobox1]" "[Item]" "[Pos]" ""
   If "[Pos]" "=" "1"
      SetVar "[display]" "[display][item][#13]"
   Endif
   AlertBox "Trace2" "N=[N], Item=[Item], Pos=[Pos]"  
EndLoop
b) However, if the values are something like ...

Dog
House
Thomas

... then you need to change ...

Code: Select all

If "[Pos]" "=" "1"
... to ...

Code: Select all

If "[Pos]" ">" "0"
... as you need to catch a match in any position other than zero.
Last edited by Gaev on Wed Nov 29, 2017 5:55 am, edited 1 time in total.
User avatar
Dudus
Posts: 120
Joined: Wed Sep 07, 2005 12:15 pm
Location: Hungary, Budapest

Re: SearchString Issue

Post by Dudus »

Thank you Gave, works perfect! :)

Dududs!
Locked