Old 29th March 2010, 09:15   #1
dbach
Member
 
Join Date: Apr 2006
Location: Somewhere in Germany
Posts: 81
${__SECTION__} is not defined if section is hidden "-"

Hi forum users,

this seems like a bug to me. When I hide a section like this ...

Section "-I am not shown" HIDDENSEC
SectionEnd

the define/var ${__SECTION__} will not be set. This is a bug, right? If not how to get the sectionname?

Kind regards,
dbach
dbach is offline   Reply With Quote
Old 29th March 2010, 16:08   #2
MSG
Major Dude
 
Join Date: Oct 2006
Posts: 1,892
Hidden sections are nameless, even if you give them a name. I filed a report about this issue ages ago, but it hasn't been fixed yet...
MSG is offline   Reply With Quote
Old 30th March 2010, 03:32   #3
Animaether
Major Dude
 
Join Date: Jun 2001
Posts: 1,173
I don't think they're nameless - they're just textless. This can almost be explained by ways of the SectionSetText function, which details that setting a section's text to "" (an empty string) will hide it.

So when you specify...

code:

Section "-I am not shown" HIDDENSEC
SectionEnd


You're doing little more than making it easier for yourself, while browsing your source file, to identify sections. The section ID will still be stored in ${HIDDENSEC}, though. So you can do something like this...

code:

!include "MUI2.nsh"

OutFile "test.exe"

setCompress off

!define MUI_PAGE_CUSTOMFUNCTION_PRE Pre
!insertmacro MUI_PAGE_COMPONENTS

Section "I am not shown" HIDDENSEC
SectionEnd

Function Pre
SectionGetText ${HIDDENSEC} $0
MessageBox MB_OK "[$0]"
SectionSetText ${HIDDENSEC} ""
FunctionEnd

!insertmacro MUI_LANGUAGE "English"



Which will pop up the section's text, and then hide it on run-time. Not sure what the point of that (getting the section text of a section that's going to be hidden) would be, though - but if you have a use for it.. go for it.
Animaether is offline   Reply With Quote
Old 30th March 2010, 08:06   #4
dbach
Member
 
Join Date: Apr 2006
Location: Somewhere in Germany
Posts: 81
Post

I want to use something like this:

PHP Code:
Var _day
Var _month
Var _year
Var _dayname
Var _hour
Var _minute
Var _second
!define SECTIONINFO '!insertmacro SECTIONINFO'
!macro SECTIONINFO
    
${GetTime"" "L" $_day $_month $_year $_dayname $_hour $_minute $_second ; $0=DD, $1=MM, $2=YYYY, $3=dayname, $4=hh, $5=mm, $6=ss
    ClearErrors
    LogText 
""
    
LogText "------------------------------------------------------------------------------"
    
LogText "${__SECTION__}"
    
LogText "($_day.$_month.$_year $_hour:$_minute:$_second)"
    
Logtext "------------------------------------------------------------------------------"
!macroend


Section 
"I am visible" VISIBLESEC
   
${SECTIONINFO}
SectionEnd

Section 
"-I am hidden" HIDDENSEC
   
${SECTIONINFO}
SectionEnd 
The first works, the second not. Is there a simple workaround so that I can contine use my macro without defining a pre?
dbach is offline   Reply With Quote
Old 30th March 2010, 12:33   #5
Animaether
Major Dude
 
Join Date: Jun 2001
Posts: 1,173
no super-simple transparent work-around that I can think of.

With the Pre function you have to remember to make the appropriate sections invisible - that's some manual editing and tracking.

One alternative would be to add a parameter to your SECTIONINFO macro and supply the information yourself, a la:
PHP Code:
!macro SECTIONINFO SectionText
...
  
LogText "${SectionText}"
...
!
macroend
...
Section "I am visible" VISIBLESEC
   
${SECTIONINFO"I am visible"
SectionEnd 

Section 
"" HIDDENSEC Section text not strictly needed here
  
${SECTIONINFO"I am hidden"
SectionEnd 
But then you have to adjust all of your SECTIONINFO invokes.
Animaether is offline   Reply With Quote
Old 30th March 2010, 12:41   #6
dbach
Member
 
Join Date: Apr 2006
Location: Somewhere in Germany
Posts: 81
Thanks Animaether,

I guess I will change my SectionInfo Macro.
dbach is offline   Reply With Quote
Old 30th March 2010, 13:44   #7
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
You could in addition only use __SECTION__ if it is defined:
code:
!ifdef __SECTION__
LogText "${__SECTION__}"
!else
LogText "${MacroParam}"
!endif


Save you repeating section names twice.

Stu
Afrow UK is offline   Reply With Quote
Old 30th March 2010, 13:59   #8
dbach
Member
 
Join Date: Apr 2006
Location: Somewhere in Germany
Posts: 81
Quote:
Originally Posted by Afrow UK View Post
You could in addition only use __SECTION__ if it is defined:
code:
!ifdef __SECTION__
LogText "${__SECTION__}"
!else
LogText "${MacroParam}"
!endif


Save you repeating section names twice.

Stu
Its doesn't work that way bcs. __SECTION__ is defined but empty. This works:
${If} "${__SECTION__}" != ""
LogText "${__SECTION__}"
${Else}
LogText "${MacroParam}"
${EndIf}
dbach is offline   Reply With Quote
Old 30th March 2010, 14:52   #9
Animaether
Major Dude
 
Join Date: Jun 2001
Posts: 1,173
wouldn't you still have to specify -something-, even if an empty string, for the macro, though?

e.g.
PHP Code:
!include "MUI2.nsh"

OutFile "test.exe"

!macro SECTIONINFO SectionText
  MessageBox MB_OK 
"${SectionText}"
!macroend
!define SECTIONINFO `!insertmacro SECTIONINFO`

Section "I am not shown" HIDDENSEC
    
${SECTIONINFO}
SectionEnd

!insertmacro MUI_LANGUAGE "English" 
fails with: !insertmacro: macro "SECTIONINFO" requires 1 parameter(s), passed 0!

Last edited by Animaether; 30th March 2010 at 15:43. Reason: "because with" - I English can do, me!
Animaether is offline   Reply With Quote
Old 30th March 2010, 15:36   #10
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
Yes of course.

Edit: dbach you could instead do:
code:
!if `${__SECTION__}` != ``
LogText "${__SECTION__}"
!else
LogText "${MacroParam}"
!endif



Stu
Afrow UK 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