Source language: Translate to:

Search in ListBox or ComboBox

Questions about using NeoBook's scripting language

Moderator: Neosoft Support

Search in ListBox or ComboBox

Postby Alex » Fri Nov 26, 2010 3:08 am

Hi,

I would like to search a word in a listbox or combobox but not an full phrase.

For example, if the phrase is: My car is black
and I only want to search car then I make:
Code: Select all
ListBoxFindItem "ListBox1" "car" "[result]"
but it doesn't show any result because I have to write the all phrase. I tried
Code: Select all
ListBoxFindItem "ListBox1" "*car*" "[result]"
but it doesn't work.

Is there a way to only search a word?

Thanks


Alex
Alex
 
Posts: 745
Joined: Sat Mar 04, 2006 4:53 am

Postby Gaev » Fri Nov 26, 2010 6:11 am

Alex:

Use ListBoxSize to get the number of entries in the ListBox ... then do a Loop/EndLoop using the returned size as the stop value in the Loop.

Within the Loop, use ...

- ListBoxGetItem to fetch the contents of the Nth item
- SearchStr to check for desired characters in the content
User avatar
Gaev
 
Posts: 3718
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Postby Alex » Fri Nov 26, 2010 6:30 am

Hello Gaev,

Thanks for the reply, but I have 250000 phrases in the variables that I put in a Listbox so I can't loop all phrases and search, it wil lbe so long.

Is there a plugin to only search in all the variable?

Thanks


Alex
Alex
 
Posts: 745
Joined: Sat Mar 04, 2006 4:53 am

About search in a listbox

Postby carlos torres » Fri Nov 26, 2010 8:31 am

Dear Alex

My suggestion is to create a database with all those statements then populate the list box and

Code: Select all
   ...///
   dbpFieldToVar "AliasDb" "Stat" "MyField" "[Sentences]" "Delimiter=[#13][#10];SkipBlanks=Yes;NoDuplicates=Yes"
   ...///


define a textbox w/ the variable to use '[FindString]', after that, look for the word

Code: Select all
dbpOpenAccessDatabase "AliasDb" "[PubDir]Data\Statements.MDB" ""
dbpOpenTable "AliasDb" "Stat" ""
dbpFind "AliasDb" "Stat" "MyField" "[FindString]" "ExactMatch=Yes;CaseSensitive=No"
If "[dbpError]" ">" ""
     MessageBox "[Title]" "[Message]" "OK" "[OkButton]"
Else
    ListBoxFindItem "MyListBox" "[FindString]" "[Found]"
    ..
EndIf



Regards,
carlost

PS: I have a doubt, because of the amount of statements how long it will take to load all of them.
User avatar
carlos torres
 
Posts: 289
Joined: Mon May 02, 2005 8:14 am
Location: Pamplona, Colombia

Postby Wrangler » Fri Nov 26, 2010 8:40 am

You may want to try searching the SOURCE of your phrases that you load the listbox with. Whether it be a text file or database. Text files are much faster to search than large databases. If found, you could display the results in a listbox.
Wrangler
--------------
"You never know about a woman. Whether she'll laugh, cry or go for a gun." - Louis L'Amour

Windows 7 Ultimate SP1 64bit
16GB Ram
Asus GTX 950 OC Strix
Software made with NeoBook
http://highdesertsoftware.com
User avatar
Wrangler
 
Posts: 1505
Joined: Thu Mar 31, 2005 11:40 pm
Location: USA

Maybe...

Postby virger » Fri Nov 26, 2010 10:17 am

.CREATE THIS FUNCTION
.Function WichLine
.{NeoBook Function}
.Version=5.60
.Language=JScript
.Param=[%par1]|Variable|To Search
.Param=[%par2]|Variable|Source String
.Param=[%pos]|Variable|Return Position
.{End}

.Put in a Button
setvar "[tx]" "Source String to Search"
.[tx] the list in ListBox or ComboBox
setvar "[sh]" "data to search"
.[sh] this case "car" (don't use *)
Call "WichLine" "[sh]" "[tx]" "[line]"
User avatar
virger
 
Posts: 510
Joined: Mon Sep 18, 2006 12:21 pm
Location: Costa Rica, America Central

Postby David de Argentina » Fri Nov 26, 2010 11:51 am

Take a look of this:

http://www.neosoftware.com/forum/viewtopic.php?t=18032

Mi devaluated cent,
David de Argentina
User avatar
David de Argentina
 
Posts: 1553
Joined: Mon Apr 04, 2005 4:13 pm
Location: Buenos Aires, Argentina

Second time...

Postby virger » Sat Nov 27, 2010 6:27 am

Maybe...
1.Download
http://openetwork.com/grep.exe

2.Create a button
setvar "[file]" "SourceFileName.txt"
setvar "[sh]" "TextToSearch"
setvar "[ret]" "FileNameToReturn.txt"
setvar "[par]" "-nic [sh] [file] > [ret]"
Run "grep.exe" "[par]" "RunOnce+Wait+Hidden" "" ""
fileread "[ret]" "All" "[rt]"
strparse "[rt]" ":" "[line]" "[dmy]"
User avatar
virger
 
Posts: 510
Joined: Mon Sep 18, 2006 12:21 pm
Location: Costa Rica, America Central

Postby Alex » Sun Nov 28, 2010 3:01 am

Hi All,

Thank you for your reply.

Carlos, your idea is good, but the DB will be very very big and it will be to slow.

David, I tried your plugin but I need to select a case to continue the code. I mean it can't execute it automatically. For example:
Code: Select all
ae_LB_Init "Rectangulo1" "[dfdzese]" "[#13][#10]" "[numdeja]" "numdeja" "o" "EntradaTexto2"

then if I write alertbox.. it will not show.

Virger, what you wrote looks good, about the Call action but I don't understand your code. Can you explain more about this please?

Thanks


Alex
Alex
 
Posts: 745
Joined: Sat Mar 04, 2006 4:53 am

Postby Alex » Tue Nov 30, 2010 12:45 am

Hi,

Does any body saw Virger? His idea looks good but it is not complete.

Thanks


Alex
Alex
 
Posts: 745
Joined: Sat Mar 04, 2006 4:53 am

The next step

Postby virger » Tue Nov 30, 2010 10:21 am

strparse "[rt]" ":" "[line]" "[dmy]"

[line1], it's LineNumber to read or take from ListBox
User avatar
virger
 
Posts: 510
Joined: Mon Sep 18, 2006 12:21 pm
Location: Costa Rica, America Central

Postby Alex » Tue Nov 30, 2010 11:37 am

Hi virger,

I can't put it in the call action because it is not javascript. Can you please explain us what was your idea?

Thanks


Alex
Alex
 
Posts: 745
Joined: Sat Mar 04, 2006 4:53 am

It´s a button

Postby virger » Tue Nov 30, 2010 1:26 pm

You're right, it's not javascript, it's just a button with an action to execute when you press the left-button of your mouse.

DESDE COSTA RICA
PURA VIDA
OXIGENO AL MUNDO
User avatar
virger
 
Posts: 510
Joined: Mon Sep 18, 2006 12:21 pm
Location: Costa Rica, America Central

Postby Alex » Thu Dec 02, 2010 12:15 pm

Hi Virger,

Thanks for the answer.

Can I search text in a listbox with it?

Thanks


Alex
Alex
 
Posts: 745
Joined: Sat Mar 04, 2006 4:53 am

I did...

Postby virger » Thu Dec 02, 2010 12:20 pm

1. Execute the accion in the button, then
2. [line1], it's LineNumber to read or take from ListBox
3. ListBoxGetItem "ListBox" "[kine1]" "[data]"

PURA VIDA
DESDE COSTA RICA
MUNDO OXIGENATE
User avatar
virger
 
Posts: 510
Joined: Mon Sep 18, 2006 12:21 pm
Location: Costa Rica, America Central

Next

Return to NeoBook Action Commands

Who is online

Users browsing this forum: No registered users and 3 guests