Archive: Extract a part from a word


Extract a part from a word
Hello,

I want to extract a certain part of a word into another variable.
In the pseudo-code below, I simulated this with a hypothetical function "WordExtract". (Taking the syntaxis of "WordFind" as example.)
Hence, I want the variable $loginData to contain "user=dummy&password="

Thanks for any help you could give.


StrCpy $R9 "DATABASE_FILE = C:/Main/Sub/SubSub/data/mydata.db?user=dummy&password="
${WordExtract} $R9 "?" "" $loginData


I solved it myself, using the code included below.
Still, I am curious whether something like this already existed.


StrCpy $rightPattern "?"

StrCpy $0 $R9
Call GetStringRightPattern
StrCpy $loginData $0

Function GetStringRightPattern

StrCpy $2 $0 1 -1
StrCmp $2 '$rightPattern' 0 +3
StrCpy $0 $0 -1
goto -3

StrCpy $1 0
IntOp $1 $1 - 1
StrCpy $2 $0 1 $1
StrCmp $2 '' end
StrCmp $2 '$rightPattern' 0 -3
IntOp $1 $1 + 1
StrCpy $0 $0 '' $1

end:
FunctionEnd


Name "Test"
OutFile "Test.exe"

!include "WordFunc.nsh"
!insertmacro WordFind

Section
${WordFind} "DATABASE_FILE = C:/Main/Sub/SubSub/data/mydata.db?user=dummy&password=" "?" "+1}" $0
MessageBox MB_OK '$$0={$0}'

${WordFind} "?DATABASE_FILE? = C:/Main/Sub/SubSub/data/mydata.db?user=dummy&password=" "?" "-1}" $R0
MessageBox MB_OK '$$0={$0}'
SectionEnd

Thank you very much, this works (and is a lot easier than
my solution ;-))