2

我试图在 NSIS 中将两个字符串合并在一起。我有两个字符串 2.1.3.0 和 0.0.0.27269,我想从它们创建的字符串是 2.1.3.27269

到目前为止,我的尝试没有奏效,这是我尝试过的:

;;$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

任何帮助都会很棒。猎人

也张贴在这里: http: //forums.winamp.com/showthread.php?p=2777308#post2777308

4

1 回答 1

4

要连接 NSIS 中的变量,您需要将它们用引号括起来。

;;$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

查看NSIS 字符串函数列表也可能会有所帮助。与使用硬编码索引拆分字符串相比,获取字符串开头和结尾部分的某些函数可以使您的代码更加健壮。

于 2011-06-02T09:42:18.323 回答