PDA

View Full Version : using FileFunc in a macro


Yathosho
24th July 2008, 21:05
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, 21:46
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
24th July 2008, 21:52
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

Yathosho
24th July 2008, 23:07
oh thanks, didn't think of that. also good to know there's no problem working like that.