Jump to content
Server Maintenance This Week. ×

Get(LastError)=401 vs Get(FoundCount)=0


This topic is 4208 days old. Please don't post here. Open a new topic instead.

Recommended Posts

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.)

Link to comment
Share on other sites

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.

  • Like 1
Link to comment
Share on other sites

  • 1 month later...

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

This topic is 4208 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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.