Archive: IF-condition gives back error macro "_If" requires 4 parameter(s), passed 3!


IF-condition gives back error macro "_If" requires 4 parameter(s), passed 3!
  Hi all,

I try to compile an NSIS script for a software I'd like to deploy. It is an addition to an allready installed software, so I want to determine the installation path via registry. The information is stored in different places for x64 and x86 machines, so I need to use an If clause.

I was googleing around for several hours and didn't find a working solution. Also I couldn't find a solution on the forums (even by using the suggestions mentioned in the "How to find the answer (READ ME FIRST)"-Thread ;)). But I am sure that you can help me :)

I found several ways to check if the system is x64 when looking for a solution, like using winver.nsh or many other possibilities.

Here i'd like to show you my initial script which I guess will work as well as winver.nsh. I guess I did something wrong concerning the IF condition:




>Function .onInit
ClearErrors
!include 'LogicLib.nsh'
; Check if x64 via determining if wow6432node key exists
EnumRegKey$0 HKLM "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node" 0
${If} 0 keyexist
InstallDirRegKey HKLM "HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\BLA" "InstallPath"
${Else}
InstallDirRegKey HKLM "HKEY_LOCAL_MACHINE\SOFTWARE\BLA" "InstallPath"
${EndIf}
>FunctionEnd
>
So far so good.
When trying to compile I get this error:

".onInit"

>ClearErrors
EnumRegKey$0 HKLMHKEY_LOCAL_MACHINESOFTWAREWow6432Node(default)
!
insertmacro: _If
>***91;COLOR="SandyBrown"***93;!insertmacro: macro "_If" requires 4 parameter(s), passed 3!***91;/COLOR***93;
>Error in script "E:\Fischi\Downloads\WORKDIR\trp_101_with_REG_nsis_DH_mui.nsi" on line 25 -- aborting creation process
>
Please please tell me what I am doing wrong!

Thanks in advance,
Dendro.

Your If usage is incorrect. Look at LogicLib.nsh for usage.

Stu


Hello Stu,

Thank you for your reply. I had a look at logiclib.nsh and was surprised that these are just textfiles that you can read with any text editor.

I read through the file and found some hints on the page that was linked within logiclib.nsh.

So I tried the following but got the same error again:


0 

>

0 

>

0 

>
Could you help me more precise since I couldn't find any kind of "real" documentation in logiclib.nsh but just some abstract definitions of the statements?

Thanks once more,
Dendro

Add some spaces to operator:

${If} $0 == "some key name"

If there is no other key in registry the $0 will be filled with empty string:

${If} $0 == ""

and the error flag is set.


Hi Slappy,

This works for me, thanks. But now it tells me that I can't use InstallDirRegKey inside a function. So I will have to figure out another solution, but that's ok. There should be other possibilities.

Thank you two for your help!


Use ReadRegStr $INSTDIR ... instead of InstallDirRegKey.

Stu