Skip to content
⌘ NSIS Forum Archive

Wildcards with StrCmp

4 posts

TheCoop004#

Wildcards with StrCmp

Is there a way to use a wildcard with a StrCmp?
With the code below we read in something like Latitude D610. We dont care about the D610 part we just want to know if the value contains Latitude so we assign Latitude to a variable and then want to compare.


OutFile "test.exe"
SilentInstall "silent"
CRCCheck on

Section
readRegstr $R7 HKLM "SOFTWARE\Test\Script" "Model"

;ASSIGNING VARIABLES
StrCpy $R1 "Latitude"

StrCmp "$R1" $R7 Laptop NotLaptop (Can we use a wild card for R1? Like R1%, or R1*)

Laptop:
MessageBox MB_OK "They are the same"

NotLapTop:
MessageBox MB_OK "Values are different"

SectionEnd

Thanks for the help
CancerFace#
You could use one of the Word Functions (NSIS Manual E.3) such as WordFind to search for Latitude in the string "Latitude D610"
CF
Afrow UK#
Or to keep it simple:

; $R0 = "Latitude D610"
StrCpy $R0 $R0 8
StrCmp $R0 "Latitude" ...

-Stu