Skip to content
⌘ NSIS Forum Archive

!define and CRLF escape codes

4 posts

Zinthose#

!define and CRLF escape codes

I got a notion in my head and wanted to try it out.

Create a multiline !define.

## Declaration
Var /GLOBAL NULL
!define NULL `$NULL\\R\\NStrCpy $NULL 0`
## Example
    Pop ${NULL}
    DetailPrint $NULL
    
## Becomes
    Pop $NULL
StrCpy $NULL 0
    DetailPrint $NULL 
At the moment this doesn't appear possible without building my own processor. The idea is an interesting whimsy and I thought I'd share in the hopes that the concept can be discussed. This might make for some interesting macros in the future if implemented.

Request Ticket
Anders#
first off, a macro can't help you?

the problem with this is, what if you want a newline in the define, !define sometext "foo$\nBar" ? This is far more common, so you would need to come up with another way to escape it. I don't think $\0 does anything, so maybe we could use that
Zinthose#
A macro would work IF the macro could be included inline. It would also make the code easier to read than mentally parsing the meta characters in your head like the previous !define example.

At this time though, adding an inline !includemacro causes a compiler error.

## Definitions
    Var /GLOBAL NULL
    !define NULL `!insertmacro NULL`
    !macro NULL
        $NULL
        StrCpy $NULL 0
    !macroend
Section
    ## Example
        Pop ${NULL}
        DetailPrint $NULL
    
    ## Becomes
        Pop !insertmacro NULL # Compile Error here: Pop expects 1 parameters, got 2.
        DetailPrint $NULL
    
    ## Then
        Pop $NULL
        StrCpy $NULL 0
        DetailPrint $NULL  
    
        Quit
SectionEnd