Verbose Print Macro

From NSIS Wiki
Jump to navigationJump to search
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