Old 4th May 2003, 08:47   #1
blazer1504
Senior Member
 
blazer1504's Avatar
 
Join Date: Dec 2001
Location: .fi
Posts: 155
Help needed

I'm having little trouble with my install script and I'm wishing that maybe some of you guys could help me with this:

Okay, what I'm trying to do here is to detect winamp2 to $1 and Winamp3 to $2

ReadRegStr $1 HKLM \
"Software\Microsoft\Windows\CurrentVersion\Uninstall\Winamp" \
"UninstallString"

ReadRegStr $2 HKLM \
"Software\Microsoft\Windows\CurrentVersion\Uninstall\Winamp3" \
"UninstallString"

These sets wa2 (if exists) to $1 & wa3 (if exists) to $2, right.
because we get the path in file format (...\winamp(3)\uninstall.exe) I need to get that file stripped, and here's where I have problems.

With what function I could erase the letter from both, $1 & $2, one by one until the last letter would be different ?

Or with what function, I could erase letter from both , $1 & $2, one by one until the first ' \ ' mark comes ?
blazer1504 is offline   Reply With Quote
Old 4th May 2003, 09:59   #2
Yathosho
Forum King
 
Yathosho's Avatar
 
Join Date: Jan 2002
Location: AT-DE
Posts: 3,366
hey,

there's a script in the avs forum, just have a look at the StripPath Function from EL-VIS. i can also offer you my avscript (version 3 out soon), will talk to you on #finnish-flash about that
Yathosho is offline   Reply With Quote
Old 4th May 2003, 13:10   #3
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
Use GetFileName here:
http://nsis.sourceforge.net/archive/...ances=0,11,211

That will get the uninstall.exe part, whether it is uninstall.exe or not.

-Stu
Afrow UK is offline   Reply With Quote
Old 4th May 2003, 15:41   #4
Joel
Debian user
(Forum King)
 
Joel's Avatar
 
Join Date: Jan 2003
Location: Arch land
Posts: 4,917
I'll be cool as feature to create variables to detect Winamp 2
and Winamp 3.
For example:
$INSTDIR means the installation directory, right?
So
code:

$WINAMP2 'will be the path for Winamp 2.x installation
$WINAMP3 'will be the path for Winamp 3.x installation



* PC: Intel Core 2 DUO E6550 @ 2.33 GHz with 2 GB RAM: Archlinux-i686 with MATE.
* Laptop: Intel Core 2 DUO T6600 @ 2.20 GHz with 4 GB RAM: Archlinux-x86-64 with MATE.
Joel is offline   Reply With Quote
Old 5th May 2003, 13:13   #5
Joost Verburg
NSIS MUI Dev
 
Join Date: Nov 2001
Posts: 3,717
You can detect it using a function, so that won't be addded (it will increase the overhead).
Joost Verburg is offline   Reply With Quote
Old 6th May 2003, 09:23   #6
blazer1504
Senior Member
 
blazer1504's Avatar
 
Join Date: Dec 2001
Location: .fi
Posts: 155
Quote:
there's a script in the avs forum, just have a look at the StripPath Function from EL-VIS. i can also offer you my avscript (version 3 out soon), will talk to you on #finnish-flash about that
The el-vis is little oldish since it's designed for Nsis1 and I couldn't get that Jheriko's script work with me (maybe I have too old version of NSIS2) and besides I like to do things by myself, so..

It's still not clear to me how the stripping does work, with what function I can erase for example 9 last letters from the path ?
blazer1504 is offline   Reply With Quote
Old 6th May 2003, 11:36   #7
Joost Verburg
NSIS MUI Dev
 
Join Date: Nov 2001
Posts: 3,717
StrCpy supports negative values for the lenght (so you can cut off chars).
Joost Verburg is offline   Reply With Quote
Old 7th May 2003, 09:11   #8
blazer1504
Senior Member
 
blazer1504's Avatar
 
Join Date: Dec 2001
Location: .fi
Posts: 155
okay let's imagine that $1 would point to C:/something/word.exe
Let's say that I'd like to get the file out and copy it to $2, would this work?

StrCpy $2 $1 -8

or is it more complicate than that?
blazer1504 is offline   Reply With Quote
Old 7th May 2003, 09:31   #9
Joost Verburg
NSIS MUI Dev
 
Join Date: Nov 2001
Posts: 3,717
Use start_offset, not maxlen.
Joost Verburg is offline   Reply With Quote
Old 8th May 2003, 08:55   #10
blazer1504
Senior Member
 
blazer1504's Avatar
 
Join Date: Dec 2001
Location: .fi
Posts: 155
um....

/me is confused. me don't understand

Please give me example how it works, and maybe I'll figure it out then..
blazer1504 is offline   Reply With Quote
Old 8th May 2003, 09:34   #11
Sunjammer
Major Dude
 
Join Date: Jun 2002
Location: Swindon, UK
Posts: 559
What Joost is saying relates to the documentation for StrCpy. The syntax is
code:
user_var(destination) str [maxlen] [start_offset]
so he is saying you need to make use of the start_offset parameter and not the maxlen parameter. This is because in your example rather than getting the file you'd actually get the path, e.g. 'C:/something/' instead of 'word.exe'.

You need to do :-
code:
StrLen $3 $1 ; how long is our string?
IntOp $4 $3 - 8 ; where do we start copying?
StrCpy $2 $1 $3 $4 ; copy $3 amount of characters from position $4 in string $1 into string $2


One thing I realised working this out is that you can't do this :-
code:
StrCpy $2 $1 0 13
i.e. I was trying to say copy all characters from position 13, bit of a shame that.
Sunjammer is offline   Reply With Quote
Old 8th May 2003, 10:30   #12
blazer1504
Senior Member
 
blazer1504's Avatar
 
Join Date: Dec 2001
Location: .fi
Posts: 155
That makes sense, thanks man , I really appreciate
blazer1504 is offline   Reply With Quote
Old 8th May 2003, 15:04   #13
pengyou
Major Dude
 
Join Date: Mar 2003
Posts: 571
Try this to copy all characters from position 13:
code:

StrCpy $2 $1 "" 13

pengyou is offline   Reply With Quote
Old 8th May 2003, 18:49   #14
blazer1504
Senior Member
 
blazer1504's Avatar
 
Join Date: Dec 2001
Location: .fi
Posts: 155
Function stripwa2
StrLen $3 $1
IntOp $4 $3 - 13
StrCpy $2 $1 $3 $4
functionEnd

I tried this like you told (used $2 in SetOutPath) but it gave me the file ( uninst.exe\plugins\blahblah ) that's what I wanted to cut off from the path

I'm sure, you can easily change that by changing some positions of $1-$4 but after trying to figure it out long enough, I thought to leave it to you smarter guys
blazer1504 is offline   Reply With Quote
Old 8th May 2003, 19:35   #15
pengyou
Major Dude
 
Join Date: Mar 2003
Posts: 571
If I understand the problem correctly, the uninstall string from the registry for Winamp2 looks like this:

code:
"x:\blah blah blah\winamp.exe" /UNINSTALL


and you want to extract just the
code:
x:\blah blah blah\
part of the string.

One way to do this is to cut off the last 22 characters and cut off the first character ("), as follows:

code:

; $1 holds "x:\blah blah blah\winamp.exe" /UNINSTALL
; Now cut off the last 22 characters (i.e. cut off winamp.exe" /UNINSTALL)

StrCpy $1 $1 -22

; Now $1 = "x:\blah blah blah\

StrCpy $1 $1 "" 1

; Now $1 = x:\blah blah blah\



If the Winamp3 uninstall string is "x:\blah blah blah\winamp3.exe" /UNINSTALL then you have to cut off 23 characters instead of 22.

Hope this helps.
pengyou is offline   Reply With Quote
Old 8th May 2003, 19:58   #16
Afrow UK
Moderator
 
Afrow UK's Avatar
 
Join Date: Nov 2002
Location: Surrey, England
Posts: 8,434
I see that there are no "\" characters until you reach "x:\blah blah blah\" in the string.
You can therefore use the GetParent function (on the NSIS Archive) and then use my GetFileName function after that.

-Stu
Afrow UK is offline   Reply With Quote
Old 9th May 2003, 12:56   #17
blazer1504
Senior Member
 
blazer1504's Avatar
 
Join Date: Dec 2001
Location: .fi
Posts: 155
ok, now it works perfect !

Thanks again guys !
blazer1504 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