Skip to content
⌘ NSIS Forum Archive

using FileFunc in a macro

4 posts

Yathosho#

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#
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}
    !include FileFunc.nsh
    !insertmacro ${FuncName}
  !endif
!macroend 
Then, to insert the functions, just add this:
${AddFileFunc} GetBaseName
${AddFileFunc} GetParent 
Comperio#
oops... I should have used !ifndef. So the first code should be like this:
!macro AddFileFunc FuncName
  !ifndef ${FuncName}
    !include FileFunc.nsh
    !insertmacro ${FuncName}
  !endif
!macroend