簡體   English   中英

NSIS 連接兩個字符串的一部分

[英]NSIS concatenating part of two strings

我試圖在 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

要連接 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 字符串函數列表也可能會有所幫助。 與使用硬編碼索引拆分字符串相比,獲取字符串開頭和結尾部分的某些函數可以使您的代碼更加健壯。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM