Yathosho
24th July 2008 22:05 UTC
using FileFunc in a macro
i'm currently polishing up a macro to get the name of a Type1 font and to install it. as my current code requires a macro from FileFunc.nsh, i was wondering if anything speaks against the usage of the following inside my macro
!ifndef FILEFUNC_INCLUDED
!include FileFunc.nsh
!insertmacro GetBaseName
!insertmacro GetParent
>!endif
Comperio
24th July 2008 22:46 UTC
If FileFunc was included, but the 2 macros weren't, then you might still have problem.
Because of how FileFunc.nsh is structured, included it more than once shouldn't cause a problem.
Here's a method I'd used in a few of my scripts:
define AddFileFunc FuncName
>!macro AddFileFunc FuncName
!ifmacrondef ${FuncName}
!includeFileFunc.nsh
!insertmacro ${FuncName}
!endif
!macroend
>
Then, to insert the functions, just add this:
GetBaseName
>${AddFileFunc} GetParent
>
Comperio
24th July 2008 22:52 UTC
oops... I should have used !ifndef. So the first code should be like this:
macro AddFileFunc FuncName
!ifndef ${FuncName}
!includeFileFunc.nsh
!insertmacro ${FuncName}
!endif
!macroend
>
Yathosho
25th July 2008 00:07 UTC
oh thanks, didn't think of that. also good to know there's no problem working like that.