我试图在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
答案 0 :(得分: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 string functions list也可能需要付费。一些函数(如获取字符串的第一部分和最后部分的函数)可以使您的代码比使用硬编码索引拆分字符串更强大。