2

I am trying to sort of merge two strings together in NSIS. I have two strings 2.1.3.0 and 0.0.0.27269 and the string I want to create from them is 2.1.3.27269

My attempts thus far haven't worked, here is what I tried:

;;$VERSION      is defined with 2.1.3.0
;;$FILEVERSION2 is defined with 0.0.0.27269

;;debug
DetailPrint ${VERSION}
DetailPrint ${FILEVERSION}

;;attempt, also it doesn't say what the variables $R0-$R2 are after values 
;;copied into them, is that normal?
StrCpy $R0 ${FILEVERSION2} 5 -5
StrCpy $R1 ${VERSION} -2 
StrCpy $R2 $R1"."$R0 

DetailPrint $R2 ;;this doesn't print a value, only prints "$R2"
!define FILEVERSION3 $R2

Any help would be great. Hunter

also posted here: http://forums.winamp.com/showthread.php?p=2777308#post2777308

Machavity
  • 30,841
  • 27
  • 92
  • 100
Hunter McMillen
  • 59,865
  • 24
  • 119
  • 170

1 Answers1

4

To concatenate variables in NSIS you need to wrap them in quote marks.

;;$VERSION      is defined with 2.1.3.0
;;$FILEVERSION2 is defined with 0.0.0.27269

;;debug
DetailPrint ${VERSION}
DetailPrint ${FILEVERSION}

StrCpy $R0 ${FILEVERSION2} 5 -5
StrCpy $R1 ${VERSION} -2 

; This concatenates the strings together with a dot
StrCpy $R2 "$R1.$R0" 

DetailPrint $R2
!define FILEVERSION3 $R2

It also might pay to have a look through the NSIS string functions list. Some of the functions such as the ones to get the first and last parts of strings could make your code more robust than splitting strings using hardcoded indexes.

David Hall
  • 32,624
  • 10
  • 90
  • 127
  • thanks for the help. I tested this and it still doesn't work, the reason I believe is I am trying to manipulate variables created by !define. This method works for user variables. What I ended up doing was writing a small executable to pass the strings into at compile-time. – Hunter McMillen Jun 02 '11 at 13:55