Page 1 of 1
fhMessageBox(...) function in FH V7
Posted: 03 Mar 2022 12:53
by tatewise
Before FH V7 this function always displayed an icon as if the 3rd parameter defaulted to "MB_ICONEXCLAMATION".
In FH V7 if the 3rd parameter is omitted or is "" then no icon at all is displayed in the message box.
Does anyone else get the same effect?
Is this a fault or is it intended new behaviour that is simply not described in the Help page for fhMessageBox?
Re: fhMessageBox(...) function in FH V7
Posted: 03 Mar 2022 14:03
by Mark1834
I hadn't realised that earlier versions of FH defaulted to an exclamation icon. IMO, the way FH7 behaves is much more logical and consistent with other apps, so I wouldn't describe it as a "fault".
I agree that the help documentation could be tidied up to make it clear that the parameter is optional and remove the old Family Historian 5 illustrations.
Re: fhMessageBox(...) function in FH V7
Posted: 03 Mar 2022 14:17
by ColeValleyGirl
strButton = fhMessageBox(strMessage[,strMessageBoxFormat[,strMessageBoxIcon[, hParentWnd]]])
[] denotes an optional parameter. Widely used in the Lua reference manual and other Lua programming resources. (It's part of the extended BNF notation often used to describe programming languages)
Re: fhMessageBox(...) function in FH V7
Posted: 03 Mar 2022 15:18
by Mark1834
Plugin help is generally specific that a parameter is optional though, rather than relying on an obscure convention that many readers will not be familiar with. Even Mike didn’t pick that up!
Re: fhMessageBox(...) function in FH V7
Posted: 03 Mar 2022 15:30
by tatewise
I am perfectly happy with the optional parameter convention. It is just that when not supplied the default has changed.
It means that any plugin updated from earlier FH versions needs the missing 3rd parameter to be specified to retain the icon.
Annoyingly, that means the 2nd parameter must also be specified even for the default value, i.e. empty string
"".
Does this need to be mentioned in
Writing and Maintaining Plugins Compatible with Versions 5, 6 & 7?
While discussing the Help page, there are several mistakes.
strMessageBoxIcon needs to say what happens if not supplied or an empty string ("") and that it is optional.
Remarks Example: needs the message box images updating without icons or the script needs correcting.
Is everyone happy I report those changes to CP?
Re: fhMessageBox(...) function in FH V7
Posted: 03 Mar 2022 15:57
by Mark1834
It's only a problem for old plugins that relied on an illogical default not changing rather than specifying the exclamation explicitly, but it is a difference (as well as the first parameter being optional in FH6 but required in FH7, so fhMessageBox('') no longer works) so should be mentioned in the KB for completeness.
Re: fhMessageBox(...) function in FH V7
Posted: 03 Mar 2022 15:57
by ColeValleyGirl
Mark1834 wrote: ↑03 Mar 2022 15:18
Plugin help is generally specific that a parameter is optional though, rather than relying on an obscure convention that many readers will not be familiar with.
Unless they read the section labelled Function Index in the Plugin Help.
Optional parameters are shown in square brackets. Some functions have many optional parameters. For some functions, like fhNewItemPtr, all parameters are optional.
Mike, if you're happy with the convention for option parameters, why would you report that the help page doesn't say it's optional?
For the rest, I don't see that it matters whether we're happy that you report things you don't like. Just report them...
I strongly suspect however that you're the only person with the problem of maintaining compatibility between plugins for V5/6 and 7. Newcomers to writing plugins will only care about V7 -- so the documentation should be accurate for their benefit.
Re: fhMessageBox(...) function in FH V7
Posted: 03 Mar 2022 16:00
by ColeValleyGirl
Mark1834 wrote: ↑03 Mar 2022 15:57
should be mentioned in the KB for completeness.
That KB article doesn't pretend to be complete, nor could it ever be.
Re: fhMessageBox(...) function in FH V7
Posted: 03 Mar 2022 16:11
by Mark1834
The KB article doesn't have a section on FH function changes as it's mainly concerned with Lua changes. Agree this change is probably too trivial to give it a section of its own, but if there are other changes with a wider impact it might be worth including in the future. Mind you, we're 18 months into most plugin authors getting their hands on FH7 and I think this is the first time a function change has been perceived as a problem, so it doesn't sound like it's a huge issue...
Re: fhMessageBox(...) function in FH V7
Posted: 03 Mar 2022 17:12
by tatewise
ColeValleyGirl wrote: ↑03 Mar 2022 15:57
Mike, if you're happy with the convention for option parameters, why would you report that the help page doesn't say it's optional?
Newcomers to writing plugins will only care about V7 -- so the documentation should be accurate for their benefit.
Everywhere else the Help pages reiterate that a parameter is optional, perhaps to save the user having to refer back to the syntax, so why not here too?
The documentation is inaccurate for FH V7 as has been discussed earlier.
Re: fhMessageBox(...) function in FH V7
Posted: 03 Mar 2022 17:53
by Mark1834
I would say “incomplete” rather than “inaccurate”, as the original claim that the new behaviour is not described is not the case, so yes, IMO, it’s worth suggesting to CP that they add a fuller description to the help narrative.
Whether the new behaviour is good or bad is subjective - it’s a breaking change, but it corrects an anomaly and improves the function in FH7 with minimal impact elsewhere.
Re: fhMessageBox(...) function in FH V7
Posted: 03 Mar 2022 18:46
by tatewise
It is inaccurate because if you run the example script the displays are not like the images shown.
In other words, the images demonstrate what happens in FH V5 (and V6) with icons by default, so are inaccurate for V7.