Archive: String manipulation outside of sections or functions ?


String manipulation outside of sections or functions ?
Working with NSIS 2.21, I am trying to inject the FileVersion into the generated installer.

If I add code like this

<code>
!ifndef CHANGELIST
!define CHANGELIST 0 ; expect string like 98765
!endif

!ifndef FILEVERSIONDOT
!define FILEVERSIONDOT 0.0.0.0 ; expect string like 9.87.65
!endif

!ifndef FILEVERSIONCOMMA
!define FILEVERSIONCOMMA 0,0,0,0 ; expect string like 9,87,65
!endif

VIProductVersion "${FILEVERSIONDOT}"
VIAddVersionKey /LANG=${LANG_ENGLISH} "ProductName" "MauiInstallExamples${PLT}"
VIAddVersionKey /LANG=${LANG_ENGLISH} "Comments" "CHANGELIST ${CHANGELIST}"
VIAddVersionKey /LANG=${LANG_ENGLISH} "CompanyName" "LeCroy Corp"
VIAddVersionKey /LANG=${LANG_ENGLISH} "FileVersion" "${FILEVERSIONCOMMA}"
</code>

early on in my .nsi script, before any section or function,
it does what I want, provided that I generate strings FILEVERSIONCOMMA and FILEVERSIONDOT from CHANGELIST number with some external program, and that I inject them into the .nsi script with "/D<string>" arguments to makensis.

Questions : could I generate strings FILEVERSIONCOMMA and FILEVERSIONDOT in my .nsi script, and how?

My understanding is that VIProductVersion and VIAddVersionKey can only be used outside sections and functions, and that commands like IntOp and StrCpy can not be used outside sections and functions.


TIA
Rudif


You could call the external with !system, let it create a header with the required definitions and !include that header in your script.


Hi Red Wine

Using !system looks like a slightly cleaner alternative than injecting /DFILEVERSIONCOMMA and /DFILEVERSIONDOT, although both should work.

You seem to confirm implicitly that there is no way to generate strings FILEVERSIONCOMMA and FILEVERSIONDOT from CHANGELIST in the main .nsi script itself, at the time of building the installer. Is this correct ?

Thanks
Rudif


http://nsis.sourceforge.net/Invoking...n_compile-time

Stu