NSIS 连接两个字符串的一部分

发布于 2024-11-12 06:02:55 字数 759 浏览 4 评论 0原文

我正在尝试在 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

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

骑趴 2024-11-19 06:02:55

要在 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 字符串函数列表 也可能会有所帮助。某些函数(例如获取字符串的第一部分和最后部分的函数)可以使您的代码比使用硬编码索引分割字符串更健壮。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文