Repeat find a possible function?


#1

Many thanks Jim for giving fast attention to making this great app even greater.
I have a question about using a repeat find function. I have a macro that brings up a window that I can put first or last name in and find the record. With help on this forum I have it now working in the new version. Just wondering if it can be extended so that after using it I could continue with repeat searches by using something like command/G? Probably not, but thought I would ask.

— Richard


#2

Why don’t you just try it? It exactly works this way.

Cmd-G finds the next record that matches your search,
cmd-opt-G finds the previous record.


#3

Well of course I did try it. That is why I was posting this question.
When I try Cmd-G I get this error message. See pix.


#4

Sorry, I thought you were talking about the normal Find / Select dialog.

You might want to read the documentation of the nextmatch or findbelow statements.


#5

I expect your procedure looks something like this.

Local Name Name = "" GetText "Enter a name:", Name Find FullName contains Name

If Name is a local variable, it no longer exists once your procedure ends. A WindowGlobal or FileGlobal would live on after the procedure without the overly broad scope of a Global, so you could use that instead of a local. You could still do it with a local, if you did it like this.

Local Name Name = "" GetText "Enter a name:", Name Execute {Find FullName contains } + quoted(Name)

This would build a formula for the Find command that contains the text in the variable, rather than the variable itself. For example, if the name you entered was George, the Find statement would read

Find FullName contains "George"

It’s kind of an exotic solution, but you don’t have any variables living on after their usefulness is done.


#6

Dave,
Before your message I had already changed the script to:

Global Name
Name = ""
GetText “What is first name?”, Name
Find «Firstname» BEGINSWITH Name
if (not info(“found”))
beep
message "No such name!"
endif

Then I made another procedure that is triggered by Cmd/G

Global Name
Name = ""
Find «Firstname» BEGINSWITH Name
if (not info(“found”))
beep
message "No such name!"
endif

This second procedure does not appear to find another record with that first name. It might be that it is finding the same record over and over again. Can’t tell.
I will try what you suggest here. See if that works.


#7

You are replacing the normal use of Cmd/G with your procedure, which just does another Find, rather than a Next or NextMatch (two names for the same command.)

Just get rid of that second procedure. Cmd/G already does exactly what you want. You don’t need to write a procedure to do it.


#8

In the meantime I did this:

Changed the first script that finds the first name to:

Windowglobal Name
Name = ""
GetText “What is first name?”, Name
Execute {Find Firstname contains } + quoted(Name)
/* Find «Firstname» BEGINSWITH Name *?
if (not info(“found”))
beep
message "No such name!"
endif

Then the second procedure I had written that find the name again to:

Windowglobal Name
Execute {Find Firstname contains } + quoted(Name)
if (not info(“found”))
beep
message "No such name!"
endif

Works great. A thing of beauty!
Thanks for your help.


#9

So I took out the second find procedure as you suggested and it does work fine. I assume that is because it ties into the usual “find” function, right?


#10

Right. It’s using the same formula as your Find statement, but it starts it’s search with the next record. The reason it failed the first time is that the formula it was using had the Name variable in it, and that variable no longer existed.


#11

I am learning :slight_smile: