Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news.swapon.de!aioe.org!.POSTED!not-for-mail From: Helpful Harry Newsgroups: comp.databases.filemaker Subject: Re: No Matching Records in a Script Find Date: Tue, 14 Apr 2015 13:51:49 +1200 Organization: Aioe.org NNTP Server Lines: 73 Message-ID: <140420151351494073%HelpfulHarry@BusyWorking.com> References: <1m2sjtb.7ukigzgagojdN%csampson@inetworld.net> <2b8f9$552b98cc$52d9780b$30967@news.ziggo.nl> NNTP-Posting-Host: hi+Y5OJvebMwqSDu7UshZA.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Complaints-To: abuse@aioe.org User-Agent: Thoth/1.8.4 (Carbon/OS X) X-Notice: Filtered by postfilter v. 0.8.2 X-Face: vIZzK[X\z-._]-_:U?l@cBtwg<{a>ggn\mH}Vs>38E,#R%7h%U0'=4;1Q=erO %[T#a{YJfGvAbWmE@f_h], Ursus 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)