nightdesigns Posted April 21, 2002 Posted April 21, 2002 I want to embed a find into a script, but the find may not always return a result (I.E. No records found). In my previous attempts, when nothing is found, a message pops up, and it leaves you with that. Since this will be running within a script, is there a way to do a "if no records found, skip" etc. Thanks -j
Ocean West Posted April 21, 2002 Posted April 21, 2002 Set error capture to ON after the perform find step insert an if statement: Status(CurrentFoundCount) =0 Show message: "Sorry no records were found." show all records enter browse mode else insert rest of your script here... endif
SteveB Posted April 21, 2002 Posted April 21, 2002 At the top of your script, include 'Set Error Capture(On)'. This allows the script to trap not finding any records (or any other error). Immediately after the Peform Find step, insert 'Status(CurrentFoundCount)'. Either save it in a Setfield, or use it in an If test (it only survives one script step).
Ocean West Posted April 21, 2002 Posted April 21, 2002 Set error capture to ON after the perform find step insert an if statement: Status(CurrentFoundCount) =0 Show message: "Sorry no records were found." show all records enter browse mode else insert rest of your script here... endif
nightdesigns Posted April 21, 2002 Author Posted April 21, 2002 quote: Originally posted by Ocean West: Set error capture to ON after the perform find step insert an if statement: Status(CurrentFoundCount) =0 Show message: "Sorry no records were found." show all records enter browse mode else insert rest of your script here... endif Just to make sure, in my case... Set error capture to ON Perform find if Status(CurrentFoundCount) =0 exit script (in my case) else continue performing script. I just ahve to make sure that nothing will popup and halt the script. It's going ot be running automatically w/out anyone attending it at certain intervals. I can't have anything stopping it.
RussBaker Posted April 21, 2002 Posted April 21, 2002 Looks fine from down here. Just to confuse you, I always use: If Status(Current Error) = 401 to see if no records were found. There has been some discussion in the forums on which one of: Status(CurrentError) = 401 or Status(CurrentFoundCount) = 0 is best but I can't remember what the outcome was. Russ
Anatoli Posted April 22, 2002 Posted April 22, 2002 quote: Originally posted by Russell Baker: Looks fine from down here. Just to confuse you, I always use: If Status(Current Error) = 401 to see if no records were found. There has been some discussion in the forums on which one of: Status(CurrentError) = 401 or Status(CurrentFoundCount) = 0 is best but I can't remember what the outcome was. Russ If FMI will change the "Status(CurrentError) = 401" to something else it will stop functioning. The second will work always.
Vaughan Posted April 22, 2002 Posted April 22, 2002 I mad a global field called ErrorCode. This hold the code for the while script, so the code can be used well after other steps have run and even after other finds have occurred. code: Set Error Capture [on] Peform Find [] Set Field [ErrorCapture, Status(CurrentErrorCode)] Set Error Capture [off] If [ErrorCode <> 0] If [ErrorCode = 401] Show Message [No records found.] Find All records Exit Script Else Show Message [An error occurred.] End If End If [ April 21, 2002, 05:27 PM: Message edited by: Vaughan ]
Recommended Posts
This topic is 8256 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now