Silvertop Posted September 23, 2005 Posted September 23, 2005 I've tried everything I could think of to get the script below to behave as I would wish, but without success. When the user fails to enter any data at the 'Enter Find Mode ' stage, (i.e. user just presses Return/Enter key)I cannot get the script to pick up the fact that no info was entered. It jumps past 'If [Get ( FoundCount ) = 0]'etc., Thanks ================== Allow User Abort [Off] Set Error Capture [On] Go to Layout ["To be cancelled List" (Link)] Enter Find Mode [] Loop Pause/Resume Script [indefinitely] Exit Loop If [isEmpty ( Link::Code )] New Record/Request End Loop Perform Find [] If [Get ( FoundCount ) = 0] Show Custom Dialog ["No Records Selected"; "No Records Selected"] Exit Script Else Perform Script ["Cancel"] End If
Ender Posted September 23, 2005 Posted September 23, 2005 Try capturing the error instead of using get(foundcount) get(lasterror) = 401 //No records found or get(lasterror) = 400 //Find criteria is empty
Silvertop Posted September 23, 2005 Author Posted September 23, 2005 Thank you ender. This worked in part. It is now trapping get(lasterror) = 400 //Find criteria is empty, but not get(lasterror) = 401 //No records found? I replaced the code between Perform Find [] and Exit Script, with the following. ======================= If [Get ( LastError ) = 400] Show Custom Dialog ["No Records"; "Find criteria is empty"] End If If [Get ( LastError ) = 401] Show Custom Dialog ["No Records"' "No records found"] End If
Ender Posted September 23, 2005 Posted September 23, 2005 Try storing the error in a global or using Else If: If [Get ( LastError ) = 400] Show Custom Dialog ["No Records"; "Find criteria is empty"] Else If [Get ( LastError ) = 401] Show Custom Dialog ["No Records"' "No records found"] End If The LastError changes after each some script steps.
Fitch Posted September 23, 2005 Posted September 23, 2005 Here are three options: // 1 - your way with "else" If [Get ( LastError ) = 400] . Show Custom Dialog ["No Records"; "Find criteria is empty"] Else If [Get ( LastError ) = 401] . Show Custom Dialog ["No Records"' "No records found"] End If // 2 - your way with storing the error in a global Set Field [ globalError ; Get ( LastError ) ] If [ globalError = 400] . Show Custom Dialog ["No Records"; "Find criteria is empty"] End If If [ globalError = 401] . Show Custom Dialog ["No Records"' "No records found"] End If // note: this can be even more fun with a table of errors that you relate from the globalError field. Search the forums for my fancy launcher example file. So it would look more like this: Set Field [ globalError ; Get ( LastError ) ] Show Custom Dialog ["Error " & Error::number ; Error::description ] // 3 - no fuss If [ Get ( LastError ) <> 0 ] . Show Custom Dialog ["Error"; "This computer will self-destruct in 30 seconds." ] End If
Silvertop Posted September 23, 2005 Author Posted September 23, 2005 Thanks for the help folks. this... If [Get ( LastError ) = 400] Show Custom Dialog ["No Records"; "Find criteria is empty"] Else If [Get ( LastError ) = 401] Show Custom Dialog ["No Records"' "No records found"] End If ...does not appear to work for me. The script ignores it completely and displays all the records in the DB?
Ender Posted September 23, 2005 Posted September 23, 2005 You might try adding that global after all, storing the error in it immediately after the Perform Find[], and seeing if there is an error. ... Perform Find[] Set Field [ globalError ; Get ( LastError ) ] ... It is important that you grab the error immediately after the Perform Find[]; don't even have #comments in between them.
stanley Posted September 23, 2005 Posted September 23, 2005 Silvertop: In your original script, the Set Error Capture[on] was capturing the wrong error, the Exit Loop If[] statement. To capture the error in the find, you should move the Set Error Capture[on] to directly BEFORE the Perform Find[] statement. -Stanley
-Queue- Posted September 23, 2005 Posted September 23, 2005 As long as error capture is enabled before the Perform Find step, it is irrelevant at which point it is enabled. I usually turn on error capture at the very beginning of a script (after disabling user abort) and then trap for any errors throughout the script.
Recommended Posts
This topic is 7003 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