Archive: !macro Suggestions


!macro Suggestions
I do have some suggestions for the compile time command "!macro":

- Introduce nesting of !macro's inside themselves so you can record them when they are inserted. This would really cut a lot of space in a file. Like this code below (w/ the suggestion below also):

!macro STRFUNC_DEFFUNC Name
!define `${Name}` `!insertmacro FUNCTION_STRING_${Name}`
!define `Un${Name}` `!insertmacro FUNCTION_STRING_Un${Name}`

!macro `FUNCTION_STRING_Un${Name}`
!define `Un${Name}` `!insertmacro FUNCTION_STRING_${Name}`
!macroend
!macroend

!insertmacro STRFUNC_DEFFUNC StrCase
!insertmacro STRFUNC_DEFFUNC StrClb
!insertmacro STRFUNC_DEFFUNC StrIOToNSIS
!insertmacro STRFUNC_DEFFUNC StrLoc
!insertmacro STRFUNC_DEFFUNC StrNSISToIO
!insertmacro STRFUNC_DEFFUNC StrRep
!insertmacro STRFUNC_DEFFUNC StrSort
!insertmacro STRFUNC_DEFFUNC StrStr
!insertmacro STRFUNC_DEFFUNC StrStrAdv
!insertmacro STRFUNC_DEFFUNC StrTok
!insertmacro STRFUNC_DEFFUNC StrTrimNewLines
(I was so excited with the size I could cut down with this, that I made StrFunc.nsh 1.07 first version based on the code above. Now that I discovered it is not that way, I saved it somewhere else so I can remember about this :))

(This code is the initial definition of the header file commands for install and uninstall for the user to use)

- Enable !macro's to have defined values (with !define) for the parameters. Like the code above suggests.

- A character on the parameter name to make that parameter optional. This should be only for the last parameters of the macro. I.e.:

!macro FUNCTION_STRING_StrStrAdv OutVar String StrToSearch *SearchDirection
- A message is appearing when ${} is used. I know, it appears like a define but it cannot be one as you can't define "" or create an user variable with brackets "{}".

- Everytime a macro (macro #1) is called with an !insertmacro(macro #2) and this macro (macro #2) tries to get a parameter value of the main macro (macro #1) and push that value for use with functions, it pushes nothing. You can't know what is causing it because MessageBox ever gives the correct value, and dumpstate says that happened only empty pushes. An example of this:

!macro TEST P1
Push `${${P1}}` ;Here is the problem
!macroend

!macro TEST2 Parameter1
!insertmacro TEST Parameter1 ;TEST2's 1st parameter name
!macroend

Macro names with defines in them already work.

What message appears when using ${}?

Your last example works fine. Look for that push line in the compiler output.

As for the rest, add a feature request. There are currently more important things to do, so it'll have to wait.


What message appears when using ${}?
"unknown variable/constant "{}" detected, ignoring"

How can it be a variable/constant if you can't !define or create a custom variable with that? I know, it's nothing really important...

Your last example works fine. Look for that push line in the compiler output.
Maybe I could test this after, as I fixed this using a different approach already on StrFunc.nsh.

Oh, the real problem was that !include was including the wrong file! I done it like this:

!include "StrFunc.nsh"

But on the current folder of the script there had this file with the same name (I was using it for backup). I can see now why some of your statements are true:

Macro names with defines in them already work.
Your last example works fine. Look for that push line in the compiler output.
[EDIT]Posted feature requests.[/EDIT]