Old 1st June 2011, 15:14   #1
mcmillhj
Junior Member
 
Join Date: Jun 2011
Posts: 2
String merge question?

Hi everyone, 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:

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

PS - Also posted on SO: http://stackoverflow.com/questions/6...of-two-strings
mcmillhj is offline   Reply With Quote
Old 1st June 2011, 16:47   #2
MSG
Major Dude
 
Join Date: Oct 2006
Posts: 1,892
You can use the macros in wordfunc.nsh to cut the strings up into sections. Then you can IntCmp the substrings. Then just concat the results.

But... if the values are defined, you already know the numbers at compiletime. Why don't you just mix them yourself?
MSG is offline   Reply With Quote
Old 1st June 2011, 17:03   #3
mcmillhj
Junior Member
 
Join Date: Jun 2011
Posts: 2
How would I mix them myself? I am not really familiar with nsis, I am only working on this to help someone else out.

Hunter
mcmillhj is offline   Reply With Quote
Old 1st June 2011, 18:20   #4
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
MSG is right you should not chop up the strings at run-time if they are constants (!define). Instead you can pass the constants to a command-line executable at compile-time via !system or !execute which does the split/join and writes that as a new !define to a .nsh file which you then !include.

Stu
Afrow UK is offline   Reply With Quote
Reply
Go Back   Winamp & Shoutcast Forums > Developer Center > NSIS Discussion

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump