Jump to content

Recommended Posts

Posted

We used to suggest scripts like the one below to install the MBS FileMaker Plugin and check for the error status. But the following script has a big problem, a little oversight on how FileMaker works. Try to guess what is wrong here:

Install Plug-In File [ Install Plugin Update if needed::Plugin File Mac ] 
Set Variable [ $LastError ; Value: Get(LastError) ] 
Set Variable [ $LastErrorDetail ; Value: Get(LastErrorDetail) ] 


The script installs the plugin and in case of an error, we like to query the error code and message. But this script never gets the last error detail! You may guess that we query the last error number and detail for the first line with the installation. But what we do is to query the detail for LastErrorDetail, we get the result from the Set Variable script line in the second line. Yes, the Set Variable will clear the error state and thus we never get the detail for the first line.

We have a fixed script:

Install Plug-In File [ Install Plugin Update if needed::Plugin File Mac ] 
Set Variable [ $r ; Value: Let([
  $lastError = Get(LastError);
  $lastErrorMessage = Get(LastErrorDetail)
]; 1) ]


This time we use a Let() statement to query both LastError and LastErrorDetail and assign it to variables. This way the Set Variable can overwrite the error state after we got the values.

If you have existing scripts using Get(LastErrorDetail), you may want to update them to use a Let statement.

Posted (edited)
5 hours ago, MonkeybreadSoftware said:

the Set Variable will clear the error state

That is a valuable observation.

I would make a small change to your calculation, though:

Let ([
$lastError = Get(LastError) ;
$lastErrorMessage = Get(LastErrorDetail)
]; 
""
) 

This way the dummy variable ($r in your example) is never created and does not occupy any memory space.


Or just eliminate the dummy variable altogether and do:

Set Variable [ $lastError ; Value: Let ( $lastErrorMessage = Get(LastErrorDetail); Get(LastError) ) ]

 

Edited by comment
×
×
  • Create New...

Important Information

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