Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.databases.filemaker > #2151 > unrolled thread

No Matching Records in a Script Find

Started bycsampson@inetworld.net (Charles H. Sampson)
First post2015-04-13 00:33 -0700
Last post2015-04-13 22:59 -0700
Articles 6 — 4 participants

Back to article view | Back to comp.databases.filemaker


Contents

  No Matching Records in a Script Find csampson@inetworld.net (Charles H. Sampson) - 2015-04-13 00:33 -0700
    Re: No Matching Records in a Script Find Ursus <ursus.kirk@ziggo.nl> - 2015-04-13 12:21 +0200
      Re: No Matching Records in a Script Find Helpful Harry <HelpfulHarry@BusyWorking.com> - 2015-04-14 13:51 +1200
        Re: No Matching Records in a Script Find clkaufmann@gmx.ch (Christoph Kaufmann) - 2015-04-14 09:13 +0200
          Re: No Matching Records in a Script Find Helpful Harry <HelpfulHarry@BusyWorking.com> - 2015-04-14 19:28 +1200
      Re: No Matching Records in a Script Find csampson@inetworld.net (Charles H. Sampson) - 2015-04-13 22:59 -0700

#2151 — No Matching Records in a Script Find

Fromcsampson@inetworld.net (Charles H. Sampson)
Date2015-04-13 00:33 -0700
SubjectNo Matching Records in a Script Find
Message-ID<1m2sjtb.7ukigzgagojdN%csampson@inetworld.net>
Is there a way, in a script, to suppress the Find message "No records
match this set of find requests"? I'd much rather the script discover
this and handle the situation than have the user respond to a process
that he might not even know is going on.

I know that I can add a dummy record to the database that satisfies the
find and delete it later. I don't like that because it's not direct. I'd
much rather for the script to ask, "Are there any records in this Found
set?" and react appropriately.

As always, FMP 8.

Charlie
-- 
Nobody in this country got rich on his own.  You built a factory--good.
But you moved your goods on roads we all paid for.  You hired workers we
all paid to educate. So keep a big hunk of the money from your factory.
But take a hunk and pay it forward.  Elizabeth Warren (paraphrased)

[toc] | [next] | [standalone]


#2152

FromUrsus <ursus.kirk@ziggo.nl>
Date2015-04-13 12:21 +0200
Message-ID<2b8f9$552b98cc$52d9780b$30967@news.ziggo.nl>
In reply to#2151
Charles H. Sampson schreef op 13-4-2015 om 09:33:
> Is there a way, in a script, to suppress the Find message "No records
> match this set of find requests"? I'd much rather the script discover
> this and handle the situation than have the user respond to a process
> that he might not even know is going on.
>
> I know that I can add a dummy record to the database that satisfies the
> find and delete it later. I don't like that because it's not direct. I'd
> much rather for the script to ask, "Are there any records in this Found
> set?" and react appropriately.
>
> As always, FMP 8.
>
> Charlie
>

Switch on error capture (is a script step you can add, might be labeled 
differently in English, but something to that extend. you'll find it 
within the first script-header)

Keep well, Erik

[toc] | [prev] | [next] | [standalone]


#2158

FromHelpful Harry <HelpfulHarry@BusyWorking.com>
Date2015-04-14 13:51 +1200
Message-ID<140420151351494073%HelpfulHarry@BusyWorking.com>
In reply to#2152
In article <2b8f9$552b98cc$52d9780b$30967@news.ziggo.nl>, Ursus
<ursus.kirk@ziggo.nl> wrote:
> Charles H. Sampson schreef op 13-4-2015 om 09:33:
> > Is there a way, in a script, to suppress the Find message "No records
> > match this set of find requests"? I'd much rather the script discover
> > this and handle the situation than have the user respond to a process
> > that he might not even know is going on.
> >
> > I know that I can add a dummy record to the database that satisfies the
> > find and delete it later. I don't like that because it's not direct. I'd
> > much rather for the script to ask, "Are there any records in this Found
> > set?" and react appropriately.
> >
> > As always, FMP 8.
> >
> > Charlie
> >
> 
> Switch on error capture (is a script step you can add, might be labeled 
> differently in English, but something to that extend. you'll find it 
> within the first script-header)
> 
> Keep well, Erik

Yep, the Set Error Capture [On] command is half the answer. That causes
FileMaker catch any errors itself rather than displaying a message to
the user. Set Error Capture [Off] of course returns FileMaker to the
normal option of displaying error messages to the user. Error capturing
automatically turns off when the script ends.

The other half of the solution is the Get(LastError) function which
allows you to see what error, if any, occurred with the previous script
commmand. The function returns a rather meaningless error code number
(with 0 meaning no error), but there's a list of what the error codes
mean at http://www.filemaker.com/help/html/error_codes.html

Because the Get(LastError) catches the error code for the IMMEDIATELY
PREVIOUS SCRIPT COMMAND, it's usually best to then use the function in
the very next command to grab any error code into a separate field /
Global field / variable which you can then check with following If
tests.

For example, a Find script might be something like:

    Enter Find Mode []
    Set Field [MyField; "Find Me"]
    Set Error Capture [On]
    Perform Find []
    Set [gErrorCode; Get(LastError)]
    If [gErrorCode] = 0]
       {perform whatever script commands are to be done 
        with the found records}
    End If
    If [gErrorCode = 401]
       Show Custom Dialog ["There are no records with the
                            text 'Find Me'"; "OK"]
    End If


If you instead had a Script that said:

    Enter Find Mode []
    Set Field [MyField; "Find Me"]
    Set Error Capture [On]
    Perform Find []
    Sort [MyField]
    Set [gErrorCode; Get(LastError)]

then the Get(LastError) function would retrieve the error code for the
Sort command, and the command error from the Find command would be
lost.

Helpful Harry  :o)

[toc] | [prev] | [next] | [standalone]


#2160

Fromclkaufmann@gmx.ch (Christoph Kaufmann)
Date2015-04-14 09:13 +0200
Message-ID<1m2uzcu.1eb5o0s1taqppoN%clkaufmann@gmx.ch>
In reply to#2158
Helpful Harry <HelpfulHarry@BusyWorking.com> wrote:

[Filemaker 5.5 or anything up to 7]
> For example, a Find script might be something like:

>     Set Error Capture [On]
>     Perform Find []
>     Set [gErrorCode; Get(LastError)]

Filemaker introduced script variables in version 8, meaning you don't
need to bother with a global field. The step would be

SetVariable ( $SearchError ; Get ( LastError ) )

Variables are like global fast, but you don't have to set them up as
fields, and they're faster. You still need global fields

a) if you want the user to enter something
b) if you need the value on the left side of relation

*****

When evaluating a scripted find, you may also use Get ( FoundCount )
rather than checking for error 401.

-- 
Christoph Kaufmann
http://clk.ch

[toc] | [prev] | [next] | [standalone]


#2161

FromHelpful Harry <HelpfulHarry@BusyWorking.com>
Date2015-04-14 19:28 +1200
Message-ID<140420151928086579%HelpfulHarry@BusyWorking.com>
In reply to#2160
In article <1m2uzcu.1eb5o0s1taqppoN%clkaufmann@gmx.ch>, Christoph
Kaufmann <clkaufmann@gmx.ch> wrote:

> Helpful Harry <HelpfulHarry@BusyWorking.com> wrote:
> 
> [Filemaker 5.5 or anything up to 7]
> > For example, a Find script might be something like:
> > 
> >     Set Error Capture [On]
> >     Perform Find []
> >     Set [gErrorCode; Get(LastError)]

A script like that will also work in older versions of FileMaker, but
you need to replace the Get(LastError) function with the
Status(CurrentError) function.



> Filemaker introduced script variables in version 8, meaning you don't
> need to bother with a global field. The step would be
> 
> SetVariable ( $SearchError ; Get ( LastError ) )
> 
> Variables are like global fast, but you don't have to set them up as
> fields, and they're faster. You still need global fields
> 
> a) if you want the user to enter something
> b) if you need the value on the left side of relation

Yep, I did say you could use a Variable instead. There may also be
occasions when you want to use a normal Field instead.



> When evaluating a scripted find, you may also use Get ( FoundCount )
> rather than checking for error 401.

True if you're only worried about not finding any records, and that's
usually the way I do it. You still need the Set Error Capture [On]
command to stop FileMaker displaying its normal error window.
i.e.
    Enter Find Mode []
    Set Field [MyField; "Find Me"]
    Set Error Capture [On]
    Perform Find []
    If [Get(FoundCount) <> 0]
       {perform whatever script commands are to be done 
        with the found records}
    Else
       Show Custom Dialog ["There are no records with the
                            text 'Find Me'"; "OK"]
    End If


Helpful Harry  :o)

[toc] | [prev] | [next] | [standalone]


#2159

Fromcsampson@inetworld.net (Charles H. Sampson)
Date2015-04-13 22:59 -0700
Message-ID<1m2uaal.16ltomm7hzqyfN%csampson@inetworld.net>
In reply to#2152
Ursus <ursus.kirk@ziggo.nl> wrote:

> Charles H. Sampson schreef op 13-4-2015 om 09:33:
> > Is there a way, in a script, to suppress the Find message "No records
> > match this set of find requests"? I'd much rather the script discover
> > this and handle the situation than have the user respond to a process
> > that he might not even know is going on.
> >
> > I know that I can add a dummy record to the database that satisfies the
> > find and delete it later. I don't like that because it's not direct. I'd
> > much rather for the script to ask, "Are there any records in this Found
> > set?" and react appropriately.
> >
> > As always, FMP 8.
> >
> > Charlie
> >
> 
> Switch on error capture (is a script step you can add, might be labeled
> differently in English, but something to that extend. you'll find it 
> within the first script-header)
> 
> Keep well, Erik

My bad.  I should have known about Switch on Error, It's even in the
Pogue book, but I had such bad luck finding anything useful there that I
didn't try to check before posting.

Sorry. I've gotten so much good advice from people following this
newsgroup that I don't like to waste their time.

In my defense (somewhat), I don't consider coming up with an empty set
as the result of a search to be an error, so I didn't think of looking
for what I wanted under error handling.

Charlie
-- 
Nobody in this country got rich on his own.  You built a factory--good.
But you moved your goods on roads we all paid for.  You hired workers we
all paid to educate. So keep a big hunk of the money from your factory.
But take a hunk and pay it forward.  Elizabeth Warren (paraphrased)

[toc] | [prev] | [standalone]


Back to top | Article view | comp.databases.filemaker


csiph-web