Verbose Print Macro: Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
(Created page with 'Category:Logging Functions {{PageAuthor|Zinthose}} == Description == Very simple macro to "[http://nsis.sourceforge.net/Docs/Chapter4.html#4.9.14.3 DetailPrint]" if "VERBOSE...')
 
(→‎Macro Source: Added !ifmacrondef to prevent errors)
 
Line 46: Line 46:


!ifndef VerbosePrint
!ifndef VerbosePrint
!define VerbosePrint "!insertmacro VerbosePrint"
    !define VerbosePrint "!insertmacro VerbosePrint"
 
    !ifmacrondef VerbosePrint
!Macro VerbosePrint MESSAGE
        !Macro VerbosePrint MESSAGE
!ifdef VERBOSE
            !ifdef VERBOSE
      DetailPrint `${MESSAGE}`
                  DetailPrint `${MESSAGE}`
!endif
            !endif
!macroend
        !macroend
 
    !endif
!endif ; VerbosePrint
!endif ; VerbosePrint
</highlight-nsis>
</highlight-nsis>

Latest revision as of 04:41, 7 June 2009

Author: Zinthose (talk, contrib)


Description

Very simple macro to "DetailPrint" if "VERBOSE" is defined. You could also easily modify this perform debugging if "DEBUG" is defined.

Usage

Example

!define VERBOSE
 
!include VerbosePrint.nsh
 
OutFile VerboseTest.exe
ShowInstDetails show
 
Section -Test
   ${VerbosePrint} 'This message will only print if VERBOSE is defined.'
SectionEnd

Macro Source

I wrapped it in an NSH file but you can easily copy and paste it into your scripts.

; -----------------------------
;       VerbosePrint.nsh
; -----------------------------
;
; Very simple macro to "DetailPrint" if "VERBOSE" is defined.
;
; Useage:
/*
    !define VERBOSE
 
    !include VerbosePrint.nsh
 
    OutFile VerboseTest.exe
    ShowInstDetails show
 
    Section -Test
        ${VerbosePrint} 'This message will only print if VERBOSE is defined.'
    SectionEnd
*/
 
 
!ifndef VerbosePrint
    !define VerbosePrint "!insertmacro VerbosePrint"
    !ifmacrondef VerbosePrint
        !Macro VerbosePrint MESSAGE
            !ifdef VERBOSE
                   DetailPrint `${MESSAGE}`
            !endif
        !macroend
    !endif
!endif ; VerbosePrint