| View previous topic :: View next topic |
| Author |
Message |
DW Contributor

Joined: 21 Mar 2003 Posts: 175 Location: UK
|
Posted: Fri Apr 02, 2004 11:28 am Post subject: Help with my find feature. |
|
|
I have a list and a dialog with lines like
127.0.0.1 localhost
123.455.666.6 localhost
etc...
I have created a find feature but its not working quite right. Would someone please take a look at it for me?
It will find the first item as a part match but then if you click to search again it moves on to the next item even if its not a match at all.
| Code: |
:Findmenu
REM ADDED THE IF FUNCTION BELOW TO STOP THIS COMMAND BEING USED WITH AN EMPTY LIST.
IF @NOT(@GREATER(@COUNT(LIST1),0))
WARN You can't search an empty list.
GOTO EVLOOP
END
%%SEARCH = @INPUT(Find what?)
IF @NOT(@OK())
GOTO EVLOOP
END
%%FOUND = 0
%%FOUND_TYPE =
%%LASTINDEX =
list seek,list1,0
:search_continue
if @match(List1,%%SEARCH)
REM ADDED THIS IF FUNCTION TO STOP THE SEARCH LOOPING.
IF @NOT(@GREATER(@INDEX(LIST1),%%LASTINDEX))
LIST SEEK,LIST1,%%LASTINDEX
INFO No other matches where found.
GOTO EVLOOP
END
dialog set,stat1,Part match found.
%%FOUND = 1
%%FOUND_TYPE = Part
if @equal(@item(List1),%%SEARCH)
dialog set,stat1,Full match found.
%%FOUND = 1
%%FOUND_TYPE = Full
end
end
if @equal(%%FOUND,1)
%%LASTINDEX = @INDEX(LIST1)
if @ask(A %%FOUND_TYPE match was found at line @index(list1)@cr()Would you like to keep searching?)
%%NEXT = @next(list1)
goto search_continue
end
else
info No matches where found.
end
|
Thank you |
|
| Back to top |
|
 |
gonzabar Newbie
Joined: 24 Jun 2001 Posts: 15 Location: Madrid, Spain
|
Posted: Fri Apr 02, 2004 12:01 pm Post subject: |
|
|
| You must init %%FOUND = 0 before goto search_continue |
|
| Back to top |
|
 |
Mac Professional Member

Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Fri Apr 02, 2004 12:36 pm Post subject: |
|
|
Not sure it helps, but here's a working search example...
__________________________________________________________________________________________________________
| Code: |
OPTION SCALE, 96
OPTION DECIMALSEP, "."
TITLE By Mac
DIALOG CREATE,"Test Program",-1,0,400,320
DIALOG ADD,BUTTON,LoadFile,4,4,96,24,"Load File"
DIALOG ADD,BUTTON,Search,4,104,48,24
DIALOG ADD,LIST,L1,32,4,392,264
rem -- Add horizontal scroll to list --
%z = @sendmsg(@winexists(~L1),$0194,2000,0)
DIALOG ADD,STATUS,Stat
DIALOG SHOW
:EVLOOP
WAIT EVENT
goto @event()
:LoadFileBUTTON
%%file = @filedlg()
if @file(%%file)
LIST LOADFILE, L1, %%file
end
goto EVLOOP
:SearchBUTTON
if @greater(1, @count(L1))
WARN Nothing to search...@tab()
goto EVLOOP
end
%%str = @input(Enter text string to search for:)
if @not(%%str)
goto EVLOOP
end
DIALOG SET, Stat, "Searching for: "%%str
LIST SEEK, L1, 0
:ContinueSearch
if @match(L1, %%str)
if @equal(%%str, @item(L1))
%%msg = "Full match"
else
%%msg = "Partial match"
end
if @ask(%%msg found at line @succ(@index(L1))@cr()@cr()Continue search?)
if @greater(@count(L1), @succ(@index(L1)))
LIST SEEK, L1, @succ(@index(L1))
goto ContinueSearch
else
INFO End of list...@tab()
end
end
else
INFO Search string NOT found...@tab()
end
DIALOG CLEAR, Stat
goto EVLOOP
:CLOSE
EXIT
|
EDIT - Streamlined this somewhat - the only difference between
a partial match and full match is the message to the user, so we
can use just one "ContinueSearch" option...
Cheers, Mac  _________________ VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361

Last edited by Mac on Fri Apr 02, 2004 1:58 pm; edited 2 times in total |
|
| Back to top |
|
 |
DW Contributor

Joined: 21 Mar 2003 Posts: 175 Location: UK
|
Posted: Fri Apr 02, 2004 1:55 pm Post subject: |
|
|
| Thanks Mac that great. I moded it for my app and it works perfect. |
|
| Back to top |
|
 |
Mac Professional Member

Joined: 08 Jul 2000 Posts: 1585 Location: Oklahoma USA
|
Posted: Fri Apr 02, 2004 2:01 pm Post subject: |
|
|
You're welcome - might wanna check the changes I made.
Cheers, Mac  _________________ VDSug.dll does file IO, check/disable menu items,
non-VDS dlls, draw functions and more...
Free download (30k dll size) at:
http://www.vdsworld.com/download.php?id=361
 |
|
| 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
|
|