August 30, 201213 yr Get(LastError)=401 vs Get(FoundCount)=0 Is there any advantage/disadvantage to using either of these, when scripting and checking if a find returns no matching records? (Obviously I always test for the last error immediately after the find.) Could either ever be tripped up and give a wrong result? I've been using FM since the early days and have always tested against error 401, but in recent months I've started to convert a system and in new scipts I've been erring towards get(foundcount), perhaps for readability... (This particular system I'm working on is v11, and will be upgraded to v12 next year.)
August 30, 201213 yr AFAIK they are equivalent for testing the result of a Find. However as you pointed out, Get( FoundCount ) is more readable, what I would call "self-commenting code," whereas with an error code I'd be compelled to include a comment.
October 17, 201213 yr Every script step has its error code, even where there is no error, code for that will be "0". So if after script step FoundRecord you get error code "401", after next script step this number will alter. Let's look Get (FoundCount) - the result of this operation is much more stable, even when the script in over. So maybe here you can feel the difference or save your time in future. Get (FoundCount) is more useful when you have several scripts running. Hope you catch the drill.
October 17, 201213 yr Not all find errors are 401. There's a few, but one that comes to mind is 400 (find criteria are empty). That will not result in an empty set, but rather a found set of the records before the find was initiated. I recommend a "belt and suspenders" calculation: Get ( LastError ) or ( Get ( FoundCount ) = 0 ) Also, keep in mind the OnModeEntry scripts will trigger on a find and the error will return at the beginning of the trigger script.
Create an account or sign in to comment