Winamp & Shoutcast Forums

Winamp & Shoutcast Forums (http://forums.winamp.com/index.php)
-   NSIS Discussion (http://forums.winamp.com/forumdisplay.php?f=65)
-   -   ${__SECTION__} is not defined if section is hidden "-" (http://forums.winamp.com/showthread.php?t=318047)

dbach 29th March 2010 09:15

${__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

MSG 29th March 2010 16:08

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...

Animaether 30th March 2010 03:32

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.

dbach 30th March 2010 08:06

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?

Animaether 30th March 2010 12:33

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.

dbach 30th March 2010 12:41

Thanks Animaether,

I guess I will change my SectionInfo Macro. :)

Afrow UK 30th March 2010 13:44

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

dbach 30th March 2010 13:59

Quote:

Originally Posted by Afrow UK (Post 2647342)
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}

Animaether 30th March 2010 14:52

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!

Afrow UK 30th March 2010 15:36

Yes of course.

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



Stu


All times are GMT. The time now is 17:25.

Copyright © 1999 - 2010 Nullsoft. All Rights Reserved.