During a discussion on requested features for FM+1, one request was for a way to get error code text instead of just a number. Some mentioned a function that retrieved it from the FMI error list site. Not being able to find such a thing through the usual Google methods, I decided to write to take matters into my own hands.
This is what I just wrote and tested (a little). It can't be done with a CF because you need the Insert from URL script step (unless you use a plugin like MBS or BaseElements). My goal here, though, was to make this as portable as possible. It's just one simple, all-FileMaker script. As it is, the only thing it needs is one field to temporarily store the downloaded web page data. Just call it similar to how you would a function, providing a value and getting a value in return.
A nice side feature if you use a global field (recommended) to store the data, and the file is hosted before you insert the value into the field, the solution will check the website only once every login and not every time the script is called. For most people that would be merely once a day--enough to stay current and not enough to be a nuisance.
This is "meatball surgery" and is just a brute force web-scrape. If anyone has a more elegant way to do this, please continue the discussion.
SCRIPT: Get Error Message From Code ( Error Number )
If [ IsEmpty ( Get ( ScriptParameter ) ) and Get ( AccountPrivilegeSetName ) ≠ "[Full Access]" ]
Exit Script [ ]
Set Variable [ $errNum; Value:Case ( IsEmpty ( Get ( ScriptParameter ) ) ; "2" ; Get ( ScriptParameter ) ) ]
Set Variable [ $url; Value:"http://www.filemaker.com/help/html/error_codes.html" ]
Set Error Capture [ On ]
If [ Get ( AccountPrivilegeSetName ) ≠ "[Full Access]" ]
Allow User Abort [ Off ]
#Retrieve web data
If [ IsEmpty ( <yourTABLE::yourGlobalField> ) ]
Insert from URL [ <yourTABLE::yourGlobalField> ; $url ] [ Select; No dialog ]
Set Variable [ $codes; <yourTABLE::yourGlobalField> ]
#Find error number in web data
Set Variable [ $start; Value:Position ( $codes ; ">" & $errNum & "<" ; 1 ; 1 ) ]
#Find text in subsequent TD element
Set Variable [ $nextName; Value:Position ( $codes ; "<a name" ; $start ; 1 ) ]
Set Variable [ $nextRt; Value:Position ( $codes ; ">" ; $nextName ; 1 ) ]
Set Variable [ $nextLft; Value:Position ( $codes ; "<" ; $nextRt ; 1 ) ]
Set Variable [ $msg; Value:Middle ( $codes ; $nextRt + 1 ; ( $nextLft - $nextRt - 1 ) ) ]
Exit Script [ Result: $msg ]