Does MadCap.OpenHelp() function have default values?
Posted: Thu Jun 14, 2018 5:01 pm
In the doc for CSH, the MadCap.OpenHelp() function is described as having 4 parameters: ID, Skin Name, Search String, and First Pick Search String Value. And the examples pretty much all look like this:
MadCap.OpenHelp('Welcome', null, null, null )
MadCap.OpenHelp(1000, null, null, null )
MadCap.OpenHelp('Company/Employees.htm', null, null, null )
Yes, there are a few example that also use another parameter or two to demonstrate the concepts. However...
I'm thinking that for most users in most scenarios, the help calls will look exactly like above, with the last 3 parameters unused and not needed, yet the developers having to enter null, null, null every. Single. Time.
In looking at https://developer.mozilla.org/en-US/doc ... parameters, I see that JavaScript does provide a capability to provide defaults, which would be overridden if the parameter is defined in the function call. I don't see anything about this in the docs, so I assume the function is not defined like that. But I'm thinking it'd work better if the function definition looked something like this:
function OpenHelp(ID=null, SkinName=null, SearchString=null, FirstPickSearchStringValue=null) {
.
.
.
}
That way, in the above examples, developers could writer this code:
MadCap.OpenHelp('Welcome')
MadCap.OpenHelp(1000)
MadCap.OpenHelp('Company/Employees.htm')
Which to me is a LOT cleaner and simpler. What say ye MadCap devs?
MadCap.OpenHelp('Welcome', null, null, null )
MadCap.OpenHelp(1000, null, null, null )
MadCap.OpenHelp('Company/Employees.htm', null, null, null )
Yes, there are a few example that also use another parameter or two to demonstrate the concepts. However...
I'm thinking that for most users in most scenarios, the help calls will look exactly like above, with the last 3 parameters unused and not needed, yet the developers having to enter null, null, null every. Single. Time.
In looking at https://developer.mozilla.org/en-US/doc ... parameters, I see that JavaScript does provide a capability to provide defaults, which would be overridden if the parameter is defined in the function call. I don't see anything about this in the docs, so I assume the function is not defined like that. But I'm thinking it'd work better if the function definition looked something like this:
function OpenHelp(ID=null, SkinName=null, SearchString=null, FirstPickSearchStringValue=null) {
.
.
.
}
That way, in the above examples, developers could writer this code:
MadCap.OpenHelp('Welcome')
MadCap.OpenHelp(1000)
MadCap.OpenHelp('Company/Employees.htm')
Which to me is a LOT cleaner and simpler. What say ye MadCap devs?