Source language: Translate to:

SearchString Issue

Questions about using NeoBook's scripting language

Moderator: Neosoft Support

SearchString Issue

Postby Dudus » Tue Nov 28, 2017 12:31 pm

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
Dudus
 
Posts: 117
Joined: Wed Sep 07, 2005 12:15 pm
Location: Hungary, Budapest

Re: SearchString Issue

Postby Gaev » Tue Nov 28, 2017 2:56 pm

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
Gaev
 
Posts: 3738
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Re: SearchString Issue

Postby Dudus » Wed Nov 29, 2017 1:28 am

Thank you Gave, works perfect! :)

Dududs!
User avatar
Dudus
 
Posts: 117
Joined: Wed Sep 07, 2005 12:15 pm
Location: Hungary, Budapest


Return to NeoBook Action Commands

Who is online

Users browsing this forum: No registered users and 1 guest