Archive: trouble with StrCmp and labels


trouble with StrCmp and labels
I'm trying to detect if Windows Media Encoder is installed and if not I want to kick it off.

Here's the code I put together and the error I'm getting. I'm at a loss why it doesn't work, then again, I've only playing with this for a few hours.

StrCmp "$0" "1" equal=installWME, nonequal=
Invalid command: :installWME

Section "WME"
Call IsWMEInstalled
Pop $0
StrCmp $0 1 installWME

:installWME
ExecWait '"$INSTDIR\WMEncoder.exe"'

SectionEnd

Function IsWMEInstalled
Push $0
Push $1

ReadRegStr $1 HKLM SOFTWARE\Classes\CLSID\{632B606B-BBC6-11D2-A329-006097C4E476} ""
Push $1
Exch $1
Pop $1
IfFileExists $1 0 noWME
StrCpy $0 0

noWME:
StrCpy $0 0
Goto done

done:
Pop $1
Exch $0

FunctionEnd


It's the other way around. It's `installWME:`, not `:installWME:`. Use the LogicLib instead, it's much simpler.


Thanks, that fixed it. Here's the next problem. I'm using the standard .NET detection script that is in the help file. When I call it in the following section it runs both found.NETFramework: and no.NETFramework. Any idea what I'm doing wrong?

I'm also checking to see if Windows Media Encoder is installed and it doesn't matter if it's installed or not, it fires off the label to start the install.

Section "DotNet"
Call IsDotNETInstalled
Pop $0
StrCmp $0 1 found.NETFramework no.NETFramework

found.NETFramework:
MessageBox MB_OK ".NET is already installed"
Pop $0

no.NETFramework:
MessageBox MB_OK "Microsoft .NET 1.1 is required. Taking you there to download it."
ExecShell "open" "http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=262D25E3-F589-4842-8157-034D1E7CF3A3"

SectionEnd


Follow the code through... What happens when you reach the label "no.NETFramework"... it shows the MessageBox, Pop's $0 (why?) and then what? Continues to run the code after the label "no.NETFramework". You need to jump over the code with a Goto instruction.

Or, like kichik has already said, use LogicLib. It really is much easier.

-Stu


Gotcha, that fixed it.
The thing that is really killing me is this Push, Pop thing. I'm use to setting variables and then pulling the values.

Now I'm getting an error when I run the installer that says Installer corrupted, invalid opcode.


That happens if you try and Pop or Shift when there's nothing on the stack. The code you've posted above will cause that error if there's only one stack item because you've got two Pop's. You don't even need the second one. Why is it there?
Have you removed it?

-Stu


Pop doesn't do that. Only a bad Exch or an invalid Reboot opcode trigger that message.


Not sure why I said them. Getting confused with my array plugin :S

-Stu