PDA

View Full Version : string help



rhosk
02-01-2004, 07:19 AM
Need a push on String.*

Can you use wildcards in any way to locate a string? I tried the below and it doesn't seem to work -

function screen()
document = Window.EnumerateProcesses(false);
for handle, title in document do
result = String.Find(title, "*.doc", 1, false);
if (result ~= -1) then
Window.Close(handle, CLOSEWND_TERMINATE);
end
end

I even tried the string.left and/or right -

function screen()
document = Window.EnumerateProcesses(false);
for handle, title in document do
result = String.Right(title, "doc", 3, false);
if (result ~= -1) then
Window.Close(handle, CLOSEWND_TERMINATE);
end
end

These crashed my computer :confused:

I'm just trying to look for any process that has the doc extension (sample only) and "do" the results. Thanks.

TJ_Tigger
02-01-2004, 08:48 AM
If you are searching for a microsoft work window try searching for "*- Microsoft Word" in your search string. I don't believe that .doc actually makes it into the title of the window.

Tigg

rhosk
02-01-2004, 08:53 AM
LOL, I'm sot searching for a doc extension, I just used that as an example, sorry. But I noticed that you used "* - string". Would this be correct to search for a partial string?

TJ_Tigger
02-01-2004, 09:08 AM
That is how I understand it.

rhosk
02-01-2004, 09:12 AM
Thanks Tigg, I'll give it a shot. Working on 2 projects at once here.

rhosk
02-01-2004, 09:55 AM
Hmm, didn't work Tigg. I've studied all the string functions, and can't find one that searches partial. Like if I wanted to say, search for everything with "system" in a process. It seems you could just use "*system*", but no workie. There's gotta be a way.

CWRIGHT
02-02-2004, 06:02 AM
Hi.

With the String.Find action, I don't think you need a wildcard character at all - it is automatically searching for a sub-string within the string, returning the position it is found. In the FOR loop example mentioned, the following would close all Windows with .doc in the title:

function screen()
document = Window.EnumerateProcesses();
for handle, title in document do
result = String.Find(title, ".doc", 1, false);
if (result ~= -1) then
Window.Close(handle, CLOSEWND_TERMINATE);
end
end
end

Hope that helps.
CW