Archive: Condition of !if


Condition of !if
  Hello !

Please, I have a problem (again, yes...).
I don't understand why my !if doesn't work !

Look my code:

!define PLUG2 ""


>!if ${PLUG2} != ""

>IfFileExists "C:\k3\studies\config\plugins\${PLUG2}" done2
Goto check2
check2:
>FindFirst $R0 $R1 "C:\k3\studies\config\plugins\${NAMEPLUG2}*.k3plug"
>FindClose $R0
StrCpy $R0 "$R1.BAK"
>Rename "C:\k3\studies\config\plugins\$R1" "C:\k3\studies\config\plugins\$R0"
>CopyFiles "$TEMP\${PLUG}\${PLUG2}" "C:\k3\studies\config\plugins\"
done2:

!endif
>
I have this error:


Usage: !if ***91;!***93; value ***91;(==,!=,<=,<,>,>=,&&,||) value2***93; ***91;...***93;

>Error in script "C:\Program Files\Veracity local installer\Client installer\Setup.nsi" on line 193 -- aborting creation process
>

Please help me ! I really don't know why !

Looks like you can't use defines in the !if check.
Edit: Wrong - read below %)

It's likely that you could use a regular !ifdef or !ifndef instead, defining or -not- defining PLUG2 as appropriate.


I don't think because this code works:


define BOOL_PLUGINS 1


>!if ${BOOL_PLUGINS} == 1

SetOutPath $TEMP

File /r "${DIRPLUGINS}\*.*"
So I can use define in a !if (I think 0_o)

Originally posted by Animaether
Looks like you can't use defines in the !if check.
I guess the problem is that the define has no value ("").
BTW: What's the sense of defining a constant which has no value?

It's likely that you could use a regular !ifdef or !ifndef instead, defining or -not- defining PLUG2 as appropriate.
AFAIK there are the following options:
If there is no value => do not define a constant and use !ifdef | !ifndef
Use a variable instead of a constant and use !if | !if !

Gunther

oh, silly me -_-

The `!define PLUG2 ""` literally defines PLUG2 as ... zilch, nothing, nada..

So when you use `!if ${PLUG2} != ""`, it's parsing that as `!if != ""`, rather than `!if "" != ""`. You'd have to define it as '""' or something silly like that.
Why not use !ifdef/!ifndef, though?


My define is here for a good reason,

This define can be equal to "" or to a string following the procedure in my previous code.

"" -> is for me a null string


ooooooooooooooh ! Okay ! =) it doesn't look like C ! =)

Ok I'll try with !ifdef/!ifndef, I don't know how to use these "things" but I will try ^^


No... it doesn't work...

error is:

!ifdef expects 1+ parameters, got 0.


If PLUG2 is programmatically defined, then you could use single quotes around the tests instead?

!define PLUG2 ""

!if '${PLUG2}' != ''
!endif


You know why ?

I will cheat ! :0 yes !


"null"


>!if ${PLUG2} != "null"

>IfFileExists "C:\k3\studies\config\plugins\${PLUG2}" done2
Goto check2
check2:
>FindFirst $R0 $R1 "C:\k3\studies\config\plugins\${NAMEPLUG2}*.k3plug"
>FindClose $R0
StrCpy $R0 "$R1.BAK"
>Rename "C:\k3\studies\config\plugins\$R1" "C:\k3\studies\config\plugins\$R0"
>CopyFiles "$TEMP\${PLUG}\${PLUG2}" "C:\k3\studies\config\plugins\"
done2:

!endif
>
That will work for the moment...

yes I will try ^^ wait a second :)


YEAAAAAAH ! =) =) =)

Thanks Animaether !

The code:


""


>!if '${PLUG2}' != '""'

>IfFileExists "C:\k3\studies\config\plugins\${PLUG2}" done2
Goto check2
check2:
>FindFirst $R0 $R1 "C:\k3\studies\config\plugins\${NAMEPLUG2}*.k3plug"
>FindClose $R0
StrCpy $R0 "$R1.BAK"
>Rename "C:\k3\studies\config\plugins\$R1" "C:\k3\studies\config\plugins\$R0"
>CopyFiles "$TEMP\${PLUG}\${PLUG2}" "C:\k3\studies\config\plugins\"
done2:

!endif
>
Thanks !