September 23, 200520 yr 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
September 23, 200520 yr Try capturing the error instead of using get(foundcount) get(lasterror) = 401 //No records found or get(lasterror) = 400 //Find criteria is empty
September 23, 200520 yr Author 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
September 23, 200520 yr 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.
September 23, 200520 yr 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
September 23, 200520 yr Author 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?
September 23, 200520 yr 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.
September 23, 200520 yr 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
September 23, 200520 yr 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.
Create an account or sign in to comment