PDA

View Full Version : Input Search Help


GoOgLe
03-26-2007, 03:15 AM
I used KEYSTROKES.DLL and put all the codes but it didnt work !!!

Global Functions :

function SendKeys(sSendString)
sSendString = "\"" ..sSendString.."\""
result = DLL.CallFunction(_SourceFolder.. "\\AutoPlay\\Docs\\dll\\KEYSTROKES.DLL", "KEYSTROKE", sSendString, DLL_RETURN_TYPE_INTEGER, DLL_CALL_STDCALL)
end

Button On Click Event :

Page.SetFocus("Input1");
--send Control F
SendKeys("\"^f\"")


Why ???

RizlaUK
03-26-2007, 04:18 AM
that search function dosent work in a inout object, all it dose is calls the native ie search dialog from within the webobject

GoOgLe
03-26-2007, 05:02 AM
how can i do search in input object ???

RizlaUK
03-26-2007, 06:07 AM
use String.Find and Input.SetSelection, with some clever code you can achive the same kind of thing

GoOgLe
03-26-2007, 06:14 AM
strText = Input.GetText("Input1");
search = Input.GetText("Input4");
strText = String.Find(strText, search, 1, true);
Input.SetSelection("Input1", 1, -1, search);

can u help with it please ???

GoOgLe
03-26-2007, 06:36 AM
strText = Input.GetText("Input1");
search = Input.GetText("Input4");
result = String.Find(strText, search, 1, true);
Input.SetSelection("Input1", 1, -1, result);

that works but selects all the text in input1 !!!!

GoOgLe
03-27-2007, 06:04 AM
can someone help me please ???? :o

mwreyf1
03-27-2007, 08:10 AM
Try this...

strText = Input.GetText("Input1");
search = Input.GetText("Input4");
searchlen = String.Length(search);
result = String.Find(strText, search, 1, true);
Input.SetSelection("Input1", result, result + searchlen -1);

GoOgLe
03-27-2007, 08:22 AM
thanks mwreyf1 that works good but how can i get the next result...

what i mean is if there r more then 1 result in input1 how will i jump the next one ???

RizlaUK
03-27-2007, 08:48 AM
start from the end of last search string

result = String.Find(strText, search+1, 1, true);

or something like that, im not on my dev pc and ams wont run properly on my laptop, so i cant test it

GoOgLe
03-27-2007, 08:54 AM
i got an error

RizlaUK
03-27-2007, 09:05 AM
like i said, im not in a position to test it

try

result = String.Find(strText, searchlen+1, 1, true);


but i think its going to take a lot more code than that,

the code you have is ok to fine the frist word, then there is text selected, so use that to make your next block of code "if selected then" and start the search from the end of the selected text

GoOgLe
03-27-2007, 09:13 AM
strText = Input.GetText("Input1");
search = Input.GetText("Input4");
searchlen = String.Length(search);
result = String.Find(strText, search, 1, true);
Input.SetSelection("Input1", result, result + searchlen -1);


selString = Input.GetSelection("Input1");
if selString then
strText = Input.GetText("Input1");
search = Input.GetText("Input4");
searchlen = String.Length(search);
result = String.Find(strText, searchlen+1, 1, true);
Input.SetSelection("Input1", result, result + searchlen -1);
end

i tried that it finds the first result and blocks it but when i click again it unblocks the result it doesnt research for the next result !!!!!

GoOgLe
03-27-2007, 11:54 AM
can someone help with the code please ???

TJ_Tigger
03-27-2007, 12:19 PM
The following code comes from the IR Project Code Viewer which has a search function in the On Key event for the page. This code uses CTRL+F to start the search and then F3 to step to the next occurance. You can find the project from my sig below to see the working code.

HTH

--CTRL+F initiate search dialog
if e_Key == 70 and e_Modifiers.ctrl then
sSearch = String.TrimRight(Dialog.Input("Enter Search String", "Enter the string for which you want to search."), nil);
if sSearch ~= "" and sSearch ~= "CANCEL" then
local sInputString = Input.GetText("Input2");
nPos = String.Find(sInputString, sSearch, 1, false);
if nPos ~= -1 then
Input.SetSelection("Input2", nPos, nPos+String.Length(sSearch)-1);
Application.Sleep(100);
local tbSel = Input.GetSelection("Input2");
Input.ScrollToLine("Input2", tbSel.LineNum);
bFound = true;
else
Dialog.Message("Info", "No occurances found.");
bFound = false;
end
end
end

if bFound then
--F3 find next dialog
if e_Key == 114 then
if sSearch ~= "" and sSearch ~= "CANCEL" then
local sInputString = Input.GetText("Input2");
nPos = String.Find(sInputString, sSearch, 1, false);
if nPos ~= -1 then
Input.SetSelection("Input2", nPos, nPos+String.Length(sSearch)-1);
Application.Sleep(100);
local tbSel = Input.GetSelection("Input2");
Input.ScrollToLine("Input2", tbSel.LineNum);
bFound = true;
else
Dialog.Message("EOF", "The End of the file has been reached.");
bFound = false;
end
end
end
end

GoOgLe
03-27-2007, 12:29 PM
sSearch = String.TrimRight(Dialog.Input("Enter Search String", "Enter the string for which you want to search."), nil);
if sSearch ~= "" and sSearch ~= "CANCEL" then
local sInputString = Input.GetText("Input1");
nPos = String.Find(sInputString, sSearch, 1, false);
if nPos ~= -1 then
Input.SetSelection("Input1", nPos, nPos+String.Length(sSearch)-1);
Application.Sleep(100);
local tbSel = Input.GetSelection("Input2");
Input.ScrollToLine("Input1", tbSel.LineNum);
bFound = true;
else
Dialog.Message("Info", "No occurances found.");
bFound = false;
end
end

if bFound then
if sSearch ~= "" and sSearch ~= "CANCEL" then
local sInputString = Input.GetText("Input1");
nPos = String.Find(sInputString, sSearch, 1, false);
if nPos ~= -1 then
Input.SetSelection("Input1", nPos, nPos+String.Length(sSearch)-1);
Application.Sleep(100);
local tbSel = Input.GetSelection("Input1");
Input.ScrollToLine("Input1", tbSel.LineNum);
bFound = true;
else
Dialog.Message("EOF", "The End of the file has been reached.");
bFound = false;
end
end
end


i put the code on button click and i got that error

TJ_Tigger
03-27-2007, 12:36 PM
make sure that you are searching the correct input object.

GoOgLe
03-27-2007, 12:46 PM
local tbSel = Input.GetSelection("Input2");
local tbSel = Input.GetSelection("Input1");

i change the input2 to input1 it was wrong but now it find the result but doesnt jump to second result !!!!

TJ_Tigger
03-27-2007, 01:43 PM
It looks like you removed the key press references. That example was specifically designed to be tied to key presses. Is this being executed from a button being pressed? If so you will have to adjust how it knows whether or not to present a new search or jump to the next one.

Maybe you can determine if you want to populate a new search or look for the next you can check to see if something is selected within the index, and if it is then you can search for the next one.

GoOgLe
03-27-2007, 01:47 PM
i tried to change it from onkey to button click...

can u please correct me with the code ???

TJ_Tigger
03-27-2007, 01:50 PM
Maybe more like this. It will prompt you to search for something if nothing is selected in the input. Now if you select something and then press the button with the following code it will then search for the next occurance. I haven't tested the code so you might have to tweak it or play with it.


if Input.GetText("Input1") == "" then
sSearch = String.TrimRight(Dialog.Input("Enter Search String", "Enter the string for which you want to search."), nil);
if sSearch ~= "" and sSearch ~= "CANCEL" then
local sInputString = Input.GetText("Input1");
nPos = String.Find(sInputString, sSearch, 1, false);
if nPos ~= -1 then
Input.SetSelection("Input1", nPos, nPos+String.Length(sSearch)-1);
Application.Sleep(100);
local tbSel = Input.GetSelection("Input1");
Input.ScrollToLine("Input1", tbSel.LineNum);
else
Dialog.Message("Info", "No occurances found.");
end
end
else --something was found so find the next item
if sSearch ~= "" and sSearch ~= "CANCEL" then
local sInputString = Input.GetText("Input1");
nPos = String.Find(sInputString, sSearch, 1, false);
if nPos ~= -1 then
Input.SetSelection("Input1", nPos, nPos+String.Length(sSearch)-1);
Application.Sleep(100);
local tbSel = Input.GetSelection("Input1");
Input.ScrollToLine("Input1", tbSel.LineNum);
else
Dialog.Message("EOF", "The End of the file has been reached.");
end
end
end

GoOgLe
03-27-2007, 02:25 PM
i couldnt manage...... :( i think i will just give up with that function :o

TJ_Tigger
03-27-2007, 02:29 PM
can you post your project or PM me with a link where I can download it I can take a look at the actual project and see why it is not working.

Tigg

RizlaUK
03-27-2007, 04:49 PM
hey tigg, how was the holladay ;)


line 18 arg 2, is giveing the error, "sSearch" is being referenced in the second block of code but it is not defined anywhere after the "else"

TJ_Tigger
03-27-2007, 05:42 PM
hey tigg, how was the holladay ;)




Hey Dino, Holiday was fantastic. Being Tigg I had to return home to Disney for a while to refresh my bouncyness. :) All refreshed.

sSearch should be defined as a global value from the previous instance, but I can see where if something is selected it would jump to that block and try to run and give an error. Not much error checking in that code, they need to do something about that coder, lazy thing.

I will play with it tonight and see if I can get a good working copy to post back.

Tigg

TJ_Tigger
03-27-2007, 06:16 PM
I had code in a couple of places and the code in the On Key event was incorrect, however the On Key event for the input had the correct code. Here it is modified and you whould be able to place this into the Find button on your project.

if Input.GetText("Input4") == "" then
nPos = 1
sSearch = String.TrimRight(Dialog.Input("Enter Search String", "Enter the string for which you want to search."), nil);
if sSearch ~= "" and sSearch ~= "CANCEL" then
local sInputString = Input.GetText("Input1");
nPos = String.Find(sInputString, sSearch, nPos, false);
if nPos ~= -1 then
Input.SetSelection("Input1", nPos, nPos+String.Length(sSearch)-1);
Application.Sleep(100);
local tbSel = Input.GetSelection("Input1");
Input.ScrollToLine("Input1", tbSel.LineNum);
Input.SetText("Input4", sSearch);
else
Dialog.Message("Info", "No occurances found.");
end
end
else --something was found so find the next item
sSearch = Input.GetText("Input4");
if sSearch ~= "" and sSearch ~= "CANCEL" then
local sInputString = Input.GetText("Input1");
nPos = String.Find(sInputString, sSearch, nPos+String.Length(sSearch), false);
if nPos ~= -1 then
Input.SetSelection("Input1", nPos, nPos+String.Length(sSearch)-1);
Application.Sleep(100);
local tbSel = Input.GetSelection("Input1");
Input.ScrollToLine("Input1", tbSel.LineNum);
else
Dialog.Message("EOF", "The End of the file has been reached.");
end
end
end

The initial click will let you start the search and then subsequent clicks will perform a find next function. It is not too intuitave, but if you clear the search box (Input4) it will then prompt you for the new search string.

GoOgLe
03-28-2007, 01:13 AM
when i type something to input4 and try to search then i get this error...

TJ_Tigger
03-28-2007, 08:01 AM
That is becaue nPos is not defined yet, you can add this line after the else statement

if not nPos then nPos = 1 end

OR

you can define nPos in the On Show event for the page.

nPos = 1

That way it is instantiated before it is needed.

Tigg

GoOgLe
03-28-2007, 08:06 AM
that works really good now

thanks alot Tigg

dorkauf89
03-10-2008, 08:46 PM
Wow... This is a awesome... BUT... I tryed it and the find works fine... The find next doesn't work though. I don't really get what Input4 object is... I know input1 object is where all the text that someone wrote is and that is where they try to find something but what is input4? I changed all the input1 in the script to txt cause that's the name of my input. Only the find works but the find next doesn't. Help... Thanks..

dorkauf89
04-04-2008, 05:25 PM
can anyone help me??