Archive: Can Functions have parameters?


Can Functions have parameters?
Is there a way to specify a parameter to a function? I'm using StrCpy to a variable now for accomplishing a "cleanup to a baseline situation", which seems to work. Is use of "push" and "pop" appropriate? Or some other approach?


# Variables
Var BlowAwayGroup

Section "Optional: Delete Files"
; remove files
StrCpy $BlowAwayGroup "Group_A"
Call BlowAwayDirectory
StrCpy $BlowAwayGroup "Group_B"
Call BlowAwayDirectory
StrCpy $BlowAwayGroup "Group_C"
Call BlowAwayDirectory
SectionEnd

Function BlowAwayDirectory
RMDir /r $INSTDIR\..\$BlowAwayGroup
RMDir /r "$PROGRAMFILES\$BlowAwayGroup"
RMDir /r "X:\Temp\$BlowAwayGroup"
RMDir /r "X:\Tmp\$BlowAwayGroup"
RMDir /r "C:\Temp\$BlowAwayGroup"
RMDir /r "C:\Tmp\$BlowAwayGroup"
RMDir /r "X:\Temp\__Stage\$BlowAwayGroup"
RMDir /r "X:\Tmp\__Stage\$BlowAwayGroup"
RMDir /r "C:\Temp\__Stage\$BlowAwayGroup"
RMDir /r "C:\Tmp\__Stage\$BlowAwayGroup"
RMDir /r "X:\Temp\Stage\$BlowAwayGroup"
RMDir /r "X:\Tmp\Stage\$BlowAwayGroup"
RMDir /r "C:\Temp\Stage\$BlowAwayGroup"
RMDir /r "C:\Tmp\Stage\$BlowAwayGroup"
FunctionEnd

yes, use push, pop and exch


E.g.

Push "blah"
Call MyFunc
Pop $R0 ; $R0 == "h"

Function MyFunc
Exch $R0
Push $R1
StrCpy $R1 $R0 1 -2
StrCpy $R0 $R1
Pop $R1
Exch $R0
FunctionEnd

There are dozens of functions on the Wiki which work in this way.

-Stu