| View previous topic :: View next topic |
| Author |
Message |
Rubes_sw Valued Contributor


Joined: 11 Jun 2001 Posts: 625 Location: Northern Ireland
|
Posted: Mon Aug 28, 2006 9:45 am Post subject: Search and Show using Table |
|
|
I've been trying to figure this out for ages:
Search a Table and scroll to the found item !
Anyone any code snipets ?
Nathan |
|
| Back to top |
|
 |
SnarlingSheep Professional Member


Joined: 13 Mar 2001 Posts: 759 Location: Michigan
|
Posted: Mon Aug 28, 2006 4:18 pm Post subject: |
|
|
I don't believe you can do this with just VDS, as the message that is sent to search a listview(table), needs a pointer to a structure which is filled with the info to search for. Sounds like alot just to find an item, but you could be searching through just the first column, or one of the many sub-columns you could have, so it needs some extra info. _________________ -Sheep
My pockets hurt... |
|
| Back to top |
|
 |
Aslan Valued Contributor


Joined: 31 May 2001 Posts: 589 Location: Memphis, TN USA
|
Posted: Mon Aug 28, 2006 5:25 pm Post subject: |
|
|
Here's a snippet from one of my apps where I the user clicks a Search button.
| Code: | %%find = @input(Search:)
If @ok()
list seek,table1,0
%%found = @match(table1,%%find)
%x = @sendmsg(~table1,$1013,@index(table1),0)
If @null(%%found)
Info %%find not found.
end
end |
|
|
| Back to top |
|
 |
SnarlingSheep Professional Member


Joined: 13 Mar 2001 Posts: 759 Location: Michigan
|
Posted: Mon Aug 28, 2006 5:35 pm Post subject: |
|
|
Ah, apparently @match() works for tables.. figures.
The line:"%x = @sendmsg(~table1,$1013,@index(table1),0)" isn't doing anything though.
That would be the message you would send, if you filled the structure and put its address in place of the 0 at the end, to find items instead of using @match().
Here's a full example:
| Code: |
DIALOG CREATE,Table Search,-1,0,524,318
DIALOG ADD,TABLE,TABLE1,52,26,458,245,Column 1[80]|Column 2[80]|Column 3[80]
DIALOG ADD,EDIT,EDIT1,24,140,180,19
DIALOG ADD,BUTTON,Find,21,327,64,24,Find,,,default
DIALOG SHOW
LIST ADD, table1, Blah
LIST ADD, table1, Test
:Evloop
wait event
goto @event()
:FindBUTTON
dialog focus, table1
%%find = @dlgtext(edit1)
If @ok()
list seek,table1,0
%%found = @match(table1,%%find)
If @null(%%found)
Info %%find not found.
end
goto evloop
:Close
exit
|
_________________ -Sheep
My pockets hurt... |
|
| Back to top |
|
 |
Rubes_sw Valued Contributor


Joined: 11 Jun 2001 Posts: 625 Location: Northern Ireland
|
Posted: Mon Aug 28, 2006 6:00 pm Post subject: |
|
|
Combining both of your code:
| Code: | %%find = @dlgtext(edit1)
dialog focus, table1
If @ok()
list seek,table1,0
%%found = @match(table1,%%find)
%x = @sendmsg(~table1,$1013,@index(table1),0)
If @null(%%found)
Info No records matching %%find have been found.
end
goto evloop |
This works great !
Thanks guys
Nathan
This code, will search all the columns within the table and then scroll to the record/row if it finds it.  |
|
| Back to top |
|
 |
Aslan Valued Contributor


Joined: 31 May 2001 Posts: 589 Location: Memphis, TN USA
|
Posted: Mon Aug 28, 2006 6:58 pm Post subject: |
|
|
Snarling Sheep,
Your example needs more items for LVM_ENSUREVISIBLE to work.
%x = @sendmsg(~table1,$1013,@index(table1),0)
=
%x = @sendmsg(~table1,@SUM($1000,19),@index(table1),0)
LVM_ENSUREVISIBLE As Int: = @SUM($1000,19)
%x = @sendmsg(~table1,$1019,@index(table1),0) does NOT work
but
%x = @sendmsg(~table1,$1013,@index(table1),0) DOES work
Funny thing I think I may have found this in one of your posts SS  |
|
| Back to top |
|
 |
SnarlingSheep Professional Member


Joined: 13 Mar 2001 Posts: 759 Location: Michigan
|
Posted: Mon Aug 28, 2006 8:00 pm Post subject: |
|
|
Hmm.. My code used $01019.
That's odd.. Whatever works I guess  _________________ -Sheep
My pockets hurt... |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum You can attach files in this forum You can download files in this forum
|
|