Archive: Simplify function and macro calls


Simplify function and macro calls
Hey. When I first thought of this I didn't believe it would work but as pleasantly shocked to find out it did. On a regular basis I will write a wrapped macro for my functions. This simplifies the calling process. Here is an example


!macro TEST TEXTVALUE
Push "${TEXTVALUE}"
Call Test
!macroend

Function Test
Exch $0
MessageBox MB_OK $0
FunctionEnd

Section
!insertmacro TEST "this is a test"
SectionEnd

This allowed me to have single line function calls. The only thing I didn't care for was have to type "!insertmacro" everytime. Lets face it, it's a somewhat long command for an ability which is suspose to save time. Anyway, I found away so you don't need the "!insertmacro" command. Using the above code as a base, if I simply add the following line.


!define TEST "!insertmacro TEST"

I can now call the following instead.


Section
${TEST} "This is a test"
SectionEnd

I hope you find this useful. Thanks

You can indeed use defines for everything. Even for commands, parameters etc. It will just be replaced by the value before the compiler parses the line.


yup, and its definitely way better than calling "!insertmacro" everytime.