Often, a script is preceded by a call to an enabler.
The purpose of enabler is to enable or disable the script (in the menu, shortcut, or icon), depending on the context.
In the below example, the EditRedo() script gets enabled only if there's something to be redone.
<ShellCommand(CanExecute:="Ena_HasRedo")> _
Public Sub EditRedo()
Page.EditRedo()
End Sub
The enabler syntax is:
<ShellCommand(CanExecute:="enablername")> _
The enabler, if present, is always right above script definition.
All enablers in GN4 are custom functions. You can locate enablers by searching for the enabler name (in this example, select Ena_HasRedo and then press SHIFT+CTRL+F).
The find results will display something like:
Find all "Ena_HasRedo", Whole word, Subfolders, Find Results 1, "Entire Solution", "*.*"
C:\tera\GN4\main\src\GN4AddIns\FredSystemAddIn\Page.vb(1447): Public Function Ena_HasRedo() As Boolean
C:\tera\GN4\main\src\GN4AddIns\FredSystemAddIn\Page.vb(10019): <ShellCommand(CanExecute:="Ena_HasRedo")> _
Matching lines: 2 Matching files: 1 Total files searched: 105
The enabler code is in Public Function Ena_HasRedo() As Boolean.
Double-click the line to get there:
Public Function Ena_HasRedo() As Boolean
Dim ipage As IPageDisp = Page
If ipage Is Nothing Then Return False
Return ipage.TestHasRedo()
End Function
All enablers function in the same way: they return True if the script is to be enabled, or False, if it shouldn't be. To do it, they perform specific (scriptable) tests.
The test in the above example returns false if no page is opened (If ipage Is Nothing Then Return False): there can't be anything to redo then. If a page is opened, it returns the result of GN4 built-in function TestHasRedo, that can be True or False.