Archive: Function Call in .onInit and un.oninit


Function Call in .onInit and un.oninit
Is there a chance, that both .onInit and un.oninit can call the same function instead of duplicating the function explicitely for un.oninit.

e.g.

Function .onInit
Call MyFunction
FunctionEnd

Function un.onInit
Call MyFunction # problem: needs un.
FunctionEnd

Function MyFunction
# many code lines
FunctionEnd

To solve the problem I don't want to duplicate MyFunction to have un.MyFunction.


Use macro

;--------------------------------
; Macro

!macro TerminateApp

DetailPrint "${STOPPING}"
fct::fct /WC '${WND_CLASS}' /WTP '${PROG_NAME}' /TIMEOUT 2000 /QUESTION '${TERM_MSG}'
Pop $0
StrCmp $0 "-1" 0 +2
Abort "${ABORTED}"

!macroend

Section "${PROG_NAME}" SEC_1

SectionIn RO

!insertmacro TerminateApp
...