3 Replies Latest reply on Jul 29, 2015 8:29 AM by philmodjunk

    Question about Get (LastError) ???

    leonhart1981_1

      Title

      Question about Get (LastError) ???

      Post

      I am watching a tutorial about script for FileMaker Pro 13. 

      There is a function that I don't understand (pls see attachment). 

      What does Get (LastError) <> 0 do? 

      Also, what does <> & 0 mean? Does <> really necessary? 

      Please help~~

       

      Screenshot_2015-07-28_15.06.30.png

        • 1. Re: Question about Get (LastError) ???
          philmodjunk

          Get ( LastError ) returns an error code for the executable step that executes just before it does. (Perform Find). If there is no error, an error code of 0 is returned. You can look up error codes in FileMaker help so that your script can both tell that an error happened and exactly what type of error. (no records found, missing find criteira...)

          <> means not equals and ≠ could have been used instead.

          And since this get function returns a numeric value and it's used where Boolean values of True or False are expected,

          IF [ Get ( LastError ) ]

          produces exactly the same result. <> 0 simply makes the intended function of this step more obvious to the person reading the script.

          Other Notes:

          If there is an error, the script will be interrupted by an error message from FileMaker before the show custom dialog can appear. If you continue the script (one of the options in the error message), you will then see the custom dialog. To avoid this confusion, this step:

          Set Error Capture [on]

          should be placed before the Perform Find.

          Since this script only check to see if an error occurred with the find, you could also use this If step:

          If [ Not Get ( FoundCount ) ]

          or

          If [ Get ( FoundCount ) = 0 ]

          and the script would be a touch less "cryptic".

          • 2. Re: Question about Get (LastError) ???
            SteveMartino

            It simply means, in this case, "if you find any error from the Perform Find script step..."  More literally if there is an error greater then 0 or less then 0, evaluate as true.  Not finding any records would result in an error.  You could also simply use If [Get (LastError)]. In some cases you could also use the opposite, If [not Get(LastError)] and branch for an opposite response  

            Edit:  Very odd that when I opened this window to type a response from my iPad, there were no responses.  Then after I submitted, my post showed up under Phil's, which was there 2 hours earlier, and marked as answered.  More bugginess and poor execution of the website

             

             

             

             

            • 3. Re: Question about Get (LastError) ???
              philmodjunk

              While I cannot reveal details. FileMaker Inc. Is working on a change that will hopefully result in a significant change for the better at some point in the future.