Old 26th February 2007, 13:16   #1
gus38
Junior Member
 
Join Date: Feb 2007
Location: Grenoble / FRANCE
Posts: 5
Use of conditional compilation !if with &&

Hello,

I'm trying to use the conditional compilation !if with boolean comparison && but it seems not working well.

My code :
!define SECTIONDEF 0x0001

!insertmacro CreateSection SECTIONDEF "SECTIONNAME" "SECIDX"

!macro CreateSection SecDef SecText SecIdx
!echo "secname = ${${SecDef}}"
!if ${${SecDef}} && 0x0008
Section "!${SecText}" ${SecIdx} ; comparison true
!else
Section "${SecText}" ${SecIdx} ; comparison false
!endif
SectionIn RO 1 2
!macroend

I change the value of SECTIONDEF, but it always pass thru the true section code.

Do you have any idea ?

Thank you and sorry for my bad english
gus38 is offline   Reply With Quote
Old 27th February 2007, 18:44   #2
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
What exactly are you trying to do? Double ampersand is a boolean operator not a binary operator. Your test only tells if both defines are not empty.

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 27th February 2007, 19:38   #3
gus38
Junior Member
 
Join Date: Feb 2007
Location: Grenoble / FRANCE
Posts: 5
Yes, thank you.
I saw after posting this thread that it was only a boolean operator.
I have submitted a feature request on Sourceforge for a binary operator "&", in order to test only a bit on a define value.
gus38 is offline   Reply With Quote
Old 27th February 2007, 19:56   #4
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
Thought that was you... You already have !define /math for that. It doesn't have bitwise AND, OR and XOR operators but I've added that for the next version.

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 27th February 2007, 21:19   #5
gus38
Junior Member
 
Join Date: Feb 2007
Location: Grenoble / FRANCE
Posts: 5
Just a precision : for !define with /math option, the value of define is the result of the operation ?

In my case, I'd like to check if some bits are present on a define value to create the section.
For example, if bit 1 and 4 of SECTIONDEF(=9) are set, I will declare my section like this :
Section "!SECTEXT"
SectionIn 1

This is in order to make different packages with only one common file with NSIS code and different headers file to define the behavior of sections (including the common file).

I hope you understand what I mean.

Thank you
gus38 is offline   Reply With Quote
Old 27th February 2007, 21:22   #6
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
Then do:
code:
!define /math result ${somedef} & 0x008
!if ${result} != 0
#...


NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 27th February 2007, 21:52   #7
gus38
Junior Member
 
Join Date: Feb 2007
Location: Grenoble / FRANCE
Posts: 5
But I can't define two time "result", and I'd like to check different bit on different case.

I can use different define name, but if I use it in macro, it will create a lot of define.

The code I'd like to do :
code:
!macro CreateSection SecDef SecText SecIdx
!if ${${SecDef}} == 0
Section "-${SecText}" ${SecIdx}
!else
!if ${${SecDef}} & 0x0008
Section "!${SecText}" ${SecIdx}
!else
Section "${SecText}" ${SecIdx}
!endif
!if ${${SecDef}} & 0x0001
SectionIn 1
!endif
!if ${${SecDef}} & 0x0002
SectionIn 2
!endif
!if ${${SecDef}} & 0x0004
SectionIn RO
!endif
!endif
!macroend

gus38 is offline   Reply With Quote
Old 1st March 2007, 18:04   #8
kichik
M.I.A.
[NSIS Dev, Mod]
 
kichik's Avatar
 
Join Date: Oct 2001
Location: Israel
Posts: 11,343
Then !undef result right after you use it.

NSIS FAQ | NSIS Home Page | Donate $
"I hear and I forget. I see and I remember. I do and I understand." -- Confucius
kichik is offline   Reply With Quote
Old 1st March 2007, 18:57   #9
gus38
Junior Member
 
Join Date: Feb 2007
Location: Grenoble / FRANCE
Posts: 5
I forgot it.
Thanks
gus38 is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump