View Single Post
Old 27th January 2021, 18:22   #4
Anders
Moderator
 
Anders's Avatar
 
Join Date: Jun 2002
Location: ${NSISDIR}
Posts: 5,358
Quote:
Originally Posted by Mupp View Post
why build a bridge that goes 99% across the river, you need 100%
There is a issue with languages here. Languages are not loaded in .onInit so a automatic solution is not possible for all languages.

With a little work on your part you can do it, all you need is GetOptions and SetCurInstType .

If you only have a single language or only care about the default language:

PHP Code:
!include LogicLib.nsh
!include FileFunc.nsh

Function SetInstTypeByName
Exch 
$3
Push 
$1
Push 
$2
ClearErrors
StrCpy 
$1 0
loop
:
    
InstTypeGetText $$2
    
${If} $!= ""
    
${AndIf} $== $3
        SetCurInstType 
$1
    
${EndIf}
    
IntOp $$1
    IfErrors 
"" loop
Pop 
$2
Pop 
$1
Pop 
$3
FunctionEnd

Function .onInit
${GetParameters$R0
${GetOptions$R0 /INSTTYPE= $0
Push 
$0
Call SetInstTypeByName
FunctionEnd 
With multiple languages you need to do some manual labor. I'm sure you can automate most of it with clever use of the pre-processor and a macro for InstType creation.

IntOp $PostCount $PostCount + 1
Anders is offline   Reply With Quote