WordFind: Difference between revisions

From NSIS Wiki
Jump to navigationJump to search
m (Updated author and download links, and changed format of some pages.)
No edit summary
 
(10 intermediate revisions by 2 users not shown)
Line 1: Line 1:
== Links ==
{{PageAuthor|Instructor}}
; Latest version of headers "nsh.zip":
: http://forums.winamp.com/showthread.php?s=&threadid=203228&goto=lastpost


== The Function ==
{{User:Instructor/Headers/Template}}
<highlight-nsis>/*
 
______________________________________________________________________________
== Function Description ==
 
<highlight-nsis>
____________________________________________________________________________


                             WordFind v2.0
                             WordFind v2.0
______________________________________________________________________________
____________________________________________________________________________
 
2004 Shengalts Aleksander (Shengalts@mail.ru)




Multi-features string function.
Multi-features string function.


Word is text between delimiter, start and end of a string.


Strings:
Strings:
Line 25: Line 22:
"...[delimiter][word-2][delimiter][word-1][delimiter]"
"...[delimiter][word-2][delimiter][word-1][delimiter]"
"...[delimiter][delimiter][word-1][delimiter][delimiter][delimiter]"
"...[delimiter][delimiter][word-1][delimiter][delimiter][delimiter]"


Syntax:  
Syntax:  
${WordFind} "[string]" "[delimiter]" "[E][options]" $var


Push "[string]"        ;[string]
"[string]"        ;[string]
                        ;  input string
                  ;  input string
Push "[delimiter]"      ;[delimiter]
"[delimiter]"      ;[delimiter]
                        ;  one or several symbols
                  ;  one or several symbols
Push "[E][options]"    ;[options]
"[E][options]"    ;[options]
                        ;  +number  : word number from start
                  ;  +number  : word number from start
                        ;  -number  : word number from end
                  ;  -number  : word number from end
                        ;  +number}  : delimiter number from start
                  ;  +number}  : delimiter number from start
                        ;              all space after this
                  ;              all space after this
                        ;              delimiter to output
                  ;              delimiter to output
                        ;  +number{  : delimiter number from start
                  ;  +number{  : delimiter number from start
                        ;              all space before this
                  ;              all space before this
                        ;              delimiter to output
                  ;              delimiter to output
                        ;  +number}} : word number from start
                  ;  +number}} : word number from start
                        ;              all space after this word
                  ;              all space after this word
                        ;              to output
                  ;              to output
                        ;  +number{{ : word number from start
                  ;  +number{{ : word number from start
                        ;              all space before this word
                  ;              all space before this word
                        ;              to output
                  ;              to output
                        ;  +number{} : word number from start
                  ;  +number{} : word number from start
                        ;              all space before and after
                  ;              all space before and after
                        ;              this word (word exclude)
                  ;              this word (word exclude)
                        ;  +number*} : word number from start
                  ;  +number*} : word number from start
                        ;              all space after this
                  ;              all space after this
                        ;              word to output with word
                  ;              word to output with word
                        ;  +number{* : word number from start
                  ;  +number{* : word number from start
                        ;              all space before this
                  ;              all space before this
                        ;              word to output with word
                  ;              word to output with word
                        ;  #        : sum of words to output
                  ;  #        : sum of words to output
                        ;  *        : sum of delimiters to output
                  ;  *        : sum of delimiters to output
                        ;  /word    : number of word to output
                  ;  /word    : number of word to output
                        ;
                  ;
                        ;[E]
                  ;[E]
                        ;  with errorlevel output
                  ;  with errorlevel output
                        ;  IfErrors:
                  ;  IfErrors:
                        ;    $var=1  delimiter not found
                  ;    $var=1  delimiter not found
                        ;    $var=2  no such word number
                  ;    $var=2  no such word number
                        ;    $var=3  syntax error
                  ;    $var=3  syntax error (Use: +1,-1},#,*,/word,...)
                        ;            (Use: +1,-1},#,*,/word,...)
                  ;[]
                        ;[]
                  ;  no errorlevel output (default)
                        ;  no errorlevel output (default)
                  ;  If some errors found then (result=input string)
                        ;  If some errors found then (result=input string)
                  ;
                        ;
$var               ;output (result)
Call WordFind          ;call function
                        ;
Pop $var               ;output (result)


Note:
Note:
+number faster then -number
-Accepted numbers 1,01,001,...
Accepted numbers 1,01,001,...
</highlight-nsis>




Example (Find word by number):
<b>Example (Find word by number):</b>
Section
<highlight-nsis>Section
Push "C:\io.sys C:\Program Files C:\WINDOWS"
${WordFind} "C:\io.sys C:\Program Files C:\WINDOWS" " C:\" "-02" $R0
Push " C:\"
; $R0="Program Files"
Push "-02"
Call WordFind
Pop $R0     ;now contain: "Program Files"
SectionEnd
SectionEnd
</highlight-nsis>


Example (Delimiter exclude):
<b>Example (Delimiter exclude):</b>
Section
<highlight-nsis>Section
Push "C:\io.sys C:\logo.sys C:\WINDOWS"
${WordFind} "C:\io.sys C:\logo.sys C:\WINDOWS" "sys" "-2}" $R0
Push "sys"
; $R0=" C:\logo.sys C:\WINDOWS"
Push "-2}"
Call WordFind
Pop $R0     ;now contain: " C:\logo.sys C:\WINDOWS"
SectionEnd
SectionEnd
</highlight-nsis>


Example (Sum of words):
<b>Example (Sum of words):</b>
Section
<highlight-nsis>Section
Push "C:\io.sys C:\logo.sys C:\WINDOWS"
${WordFind} "C:\io.sys C:\logo.sys C:\WINDOWS" " C:\" "#" $R0
Push " C:\"
; $R0="3"
Push "#"
Call WordFind
Pop $R0     ;now contain: "3"
SectionEnd
SectionEnd
</highlight-nsis>


Example (Sum of delimiters):
<b>Example (Sum of delimiters):</b>
Section
<highlight-nsis>Section
Push "C:\io.sys C:\logo.sys C:\WINDOWS"
${WordFind} "C:\io.sys C:\logo.sys C:\WINDOWS" "sys" "*" $R0
Push "sys"
; $R0="2"
Push "*"
Call WordFind
Pop $R0     ;now contain: "2"
SectionEnd
SectionEnd
</highlight-nsis>


Example (Find word number):
<b>Example (Find word number):</b>
Section
<highlight-nsis>Section
Push "C:\io.sys C:\Program Files C:\WINDOWS"
${WordFind} "C:\io.sys C:\Program Files C:\WINDOWS" " " "/Files" $R0
Push " "
; $R0="3"
Push "/Files"
Call WordFind
Pop $R0     ;now contain: "3"
SectionEnd
SectionEnd
</highlight-nsis>


Example ( }} ):
<b>Example ( }} ):</b>
Section
<highlight-nsis>Section
Push "C:\io.sys C:\logo.sys C:\WINDOWS"
${WordFind} "C:\io.sys C:\logo.sys C:\WINDOWS" " " "+2}}" $R0
Push " "
; $R0=" C:\WINDOWS"
Push "+2}}"
Call WordFind
Pop $R0     ;now contain: " C:\WINDOWS"
SectionEnd
SectionEnd
</highlight-nsis>


Example ( {} ):
<b>Example ( {} ):</b>
Section
<highlight-nsis>Section
Push "C:\io.sys C:\logo.sys C:\WINDOWS"
${WordFind} "C:\io.sys C:\logo.sys C:\WINDOWS" " " "+2{}" $R0
Push " "
; $R0="C:\io.sys C:\WINDOWS"
Push "+2{}"
Call WordFind
Pop $R0     ;now contain: "C:\io.sys C:\WINDOWS"
SectionEnd
SectionEnd
</highlight-nsis>


Example ( *} ):
<b>Example ( *} ):</b>
Section
<highlight-nsis>Section
Push "C:\io.sys C:\logo.sys C:\WINDOWS"
${WordFind} "C:\io.sys C:\logo.sys C:\WINDOWS" " " "+2*}" $R0
Push " "
; $R0="C:\logo.sys C:\WINDOWS"
Push "+2*}"
Call WordFind
Pop $R0     ;now contain: "C:\logo.sys C:\WINDOWS"
SectionEnd
SectionEnd
</highlight-nsis>


Example (Get parent directory):
<b>Example (Get parent directory):</b>
Section
<highlight-nsis>Section
StrCpy $R0 "C:\Program Files\NSIS\NSIS.chm"
StrCpy $R0 "C:\Program Files\NSIS\NSIS.chm"
          ;"C:\Program Files\NSIS\Include\"
;           "C:\Program Files\NSIS\Include\"
          ;"C:\\Program Files\\NSIS\\NSIS.chm"
;           "C:\\Program Files\\NSIS\\NSIS.chm"


Push "$R0"
${WordFind} "$R0" "\" "-2{*" $R0
Push "\"
; $R0="C:\Program Files\NSIS"
Push "-2{*"
;     "C:\\Program Files\\NSIS"
Call WordFind
Pop $R0     ;now contain: "C:\Program Files\NSIS"
            ;             "C:\\Program Files\\NSIS"
SectionEnd
SectionEnd
</highlight-nsis>


Example (Coordinates):
<b>Example (Coordinates):</b>
Section
<highlight-nsis>Section
Push "C:\io.sys C:\logo.sys C:\WINDOWS"
${WordFind} "C:\io.sys C:\logo.sys C:\WINDOWS" ":\lo" "E+1{" $R0
Push ":\lo"
; $R0="C:\io.sys C"
Push "E+1{"
Call WordFind
Pop $R0                   ;now contain: "C:\io.sys C"
IfErrors end
IfErrors end


StrLen $0 $R0            ; $0 = Start position of word (11)
StrLen $0 $R0            ; $0 = Start position of word (11)
StrLen $1 ':\lo'          ; $1 = Word length (4)
StrLen $1 ':\lo'          ; $1 = Word leght (4)
; StrCpy $R0 $R1 $1 $0    ; $R0 = :\lo
; StrCpy $R0 $R1 $1 $0    ; $R0 = :\lo


end:
end:
SectionEnd
SectionEnd
</highlight-nsis>


Example (With errorlevel output):
<b>Example (With errorlevel output):</b>
Section
<highlight-nsis>Section
Push "[string]"
${WordFind} "[string]" "[delimiter]" "E[options]" $R0
Push "[delimiter]"
Push "E[options]"
Call WordFind
Pop $R0


IfErrors 0 end
IfErrors 0 end
Line 201: Line 171:
end:
end:
SectionEnd
SectionEnd
</highlight-nsis>


Example (Without errorlevel output):
<b>Example (Without errorlevel output):</b>
Section
<highlight-nsis>Section
Push "C:\io.sys C:\logo.sys"
${WordFind} "C:\io.sys C:\logo.sys" "_" "+1" $R0
Push "_"
 
Push "+1"
; $R0="C:\io.sys C:\logo.sys" (error: delimiter "_" not found)
Call WordFind
Pop $R0     ;now contain: "C:\io.sys C:\logo.sys"
            ;(error: delimiter "_" not found)
SectionEnd
SectionEnd
</highlight-nsis>


Example (If found):
<b>Example (If found):</b>
Section
<highlight-nsis>Section
Push "C:\io.sys C:\logo.sys"
${WordFind} "C:\io.sys C:\logo.sys" ":\lo" "E+1{" $R0
Push ":\lo"
Push "E+1{"
Call WordFind
Pop $R0


IfErrors notfound found
IfErrors notfound found
Line 228: Line 193:
end:
end:
SectionEnd
SectionEnd
</highlight-nsis>


Example (If found 2):
<b>Example (If found 2):</b>
Section
<highlight-nsis>Section
Push "C:\io.sys C:\logo.sys"
${WordFind} "C:\io.sys C:\logo.sys" ":\lo" "+1{" $R0
Push ":\lo"
Push "+1{"
Call WordFind
Pop $R0


StrCmp $R0 "C:\io.sys C:\logo.sys" notfound found        ; error?
StrCmp $R0 "C:\io.sys C:\logo.sys" notfound found        ; error?
Line 245: Line 207:
end:
end:
SectionEnd
SectionEnd
</highlight-nsis>


Example (To accept one word in string if delimiter not found):
<b>Example (To accept one word in string if delimiter not found):</b>
Section
<highlight-nsis>Section
StrCpy $0 'OneWord'
StrCpy $0 'OneWord'
StrCpy $1 1
StrCpy $1 1


loop:
loop:
Push "$0"
${WordFind} "$0" " " "E+$1" $R0
Push " "
Push "E+$1"
Call WordFind
Pop $R0
 
IfErrors 0 code
IfErrors 0 code
StrCmp $1$R0 11 0 error
StrCmp $1$R0 11 0 error
Line 273: Line 231:


end:
end:
; $R0 now contain: "OneWord"
; $R0="OneWord"
SectionEnd*/
SectionEnd
</highlight-nsis>


== Function Code==


;---------------------------------------------------------------------------
<highlight-nsis>
Function WordFind
Function WordFind
!define WordFind `!insertmacro WordFindCall`
!macro WordFindCall _STRING _DELIMITER _OPTION _RESULT
Push `${_STRING}`
Push `${_DELIMITER}`
Push `${_OPTION}`
Call WordFind
Pop ${_RESULT}
!macroend
Exch $1
Exch $1
Exch
Exch
Line 340: Line 310:
StrCpy $8 $R0 $7 $6
StrCpy $8 $R0 $7 $6
StrCmp $8$5 0 error1
StrCmp $8$5 0 error1
StrCmp $8 '' 0 +5
StrCmp $8 '' +2
StrCmp $8 $0 +5 preloop
StrCmp $3 '{' minus
StrCmp $3 '{' minus
StrCmp $3 '}' minus
StrCmp $3 '}' minus
StrCmp $2 '*' minus
StrCmp $2 '*' minus
StrCmp $5 $6 minus +6
StrCmp $5 $6 minus +5
StrCmp $8 $0 0 preloop
StrCmp $3 '{' +4
StrCmp $3 '{' +4
StrCmp $3 '}' +3
StrCmp $3 '}' +3
Line 457: Line 427:
</highlight-nsis>
</highlight-nsis>


Page author: [[User:Instructor|Instructor]]
[[Category:String Functions]]

Latest revision as of 11:00, 30 November 2005

Author: Instructor (talk, contrib)


Page for NSIS 2.07 and below users

You can use the latest version of headers (recommended) or the following function code (put the function code in your script before calling it)

Function Description

____________________________________________________________________________
 
                            WordFind v2.0
____________________________________________________________________________
 
 
Multi-features string function.
 
 
Strings:
"[word+1][delimiter][word+2][delimiter][word+3]..."
"[delimiter][word+1][delimiter][word+2][delimiter]..."
"[delimiter][delimiter][word+1][delimiter][delimiter][delimiter]..."
"...[word-3][delimiter][word-2][delimiter][word-1]"
"...[delimiter][word-2][delimiter][word-1][delimiter]"
"...[delimiter][delimiter][word-1][delimiter][delimiter][delimiter]"
 
Syntax: 
${WordFind} "[string]" "[delimiter]" "[E][options]" $var
 
"[string]"         ;[string]
                   ;  input string
"[delimiter]"      ;[delimiter]
                   ;  one or several symbols
"[E][options]"     ;[options]
                   ;  +number   : word number from start
                   ;  -number   : word number from end
                   ;  +number}  : delimiter number from start
                   ;              all space after this
                   ;              delimiter to output
                   ;  +number{  : delimiter number from start
                   ;              all space before this
                   ;              delimiter to output
                   ;  +number}} : word number from start
                   ;              all space after this word
                   ;              to output
                   ;  +number{{ : word number from start
                   ;              all space before this word
                   ;              to output
                   ;  +number{} : word number from start
                   ;              all space before and after
                   ;              this word (word exclude)
                   ;  +number*} : word number from start
                   ;              all space after this
                   ;              word to output with word
                   ;  +number{* : word number from start
                   ;              all space before this
                   ;              word to output with word
                   ;  #         : sum of words to output
                   ;  *         : sum of delimiters to output
                   ;  /word     : number of word to output
                   ;
                   ;[E]
                   ;  with errorlevel output
                   ;  IfErrors:
                   ;     $var=1  delimiter not found
                   ;     $var=2  no such word number
                   ;     $var=3  syntax error (Use: +1,-1},#,*,/word,...)
                   ;[]
                   ;  no errorlevel output (default)
                   ;  If some errors found then (result=input string)
                   ;
$var               ;output (result)
 
Note:
-Accepted numbers 1,01,001,...


Example (Find word by number):

Section
	${WordFind} "C:\io.sys C:\Program Files C:\WINDOWS" " C:\" "-02" $R0
	; $R0="Program Files"
SectionEnd

Example (Delimiter exclude):

Section
	${WordFind} "C:\io.sys C:\logo.sys C:\WINDOWS" "sys" "-2}" $R0
	; $R0=" C:\logo.sys C:\WINDOWS"
SectionEnd

Example (Sum of words):

Section
	${WordFind} "C:\io.sys C:\logo.sys C:\WINDOWS" " C:\" "#" $R0
	; $R0="3"
SectionEnd

Example (Sum of delimiters):

Section
	${WordFind} "C:\io.sys C:\logo.sys C:\WINDOWS" "sys" "*" $R0
	; $R0="2"
SectionEnd

Example (Find word number):

Section
	${WordFind} "C:\io.sys C:\Program Files C:\WINDOWS" " " "/Files" $R0
	; $R0="3"
SectionEnd

Example ( }} ):

Section
	${WordFind} "C:\io.sys C:\logo.sys C:\WINDOWS" " " "+2}}" $R0
	; $R0=" C:\WINDOWS"
SectionEnd

Example ( {} ):

Section
	${WordFind} "C:\io.sys C:\logo.sys C:\WINDOWS" " " "+2{}" $R0
	; $R0="C:\io.sys C:\WINDOWS"
SectionEnd

Example ( *} ):

Section
	${WordFind} "C:\io.sys C:\logo.sys C:\WINDOWS" " " "+2*}" $R0
	; $R0="C:\logo.sys C:\WINDOWS"
SectionEnd

Example (Get parent directory):

Section
	StrCpy $R0 "C:\Program Files\NSIS\NSIS.chm"
;	           "C:\Program Files\NSIS\Include\"
;	           "C:\\Program Files\\NSIS\\NSIS.chm"
 
	${WordFind} "$R0" "\" "-2{*" $R0
	; $R0="C:\Program Files\NSIS"
	;     "C:\\Program Files\\NSIS"
SectionEnd

Example (Coordinates):

Section
	${WordFind} "C:\io.sys C:\logo.sys C:\WINDOWS" ":\lo" "E+1{" $R0
	; $R0="C:\io.sys C"
	IfErrors end
 
	StrLen $0 $R0             ; $0 = Start position of word (11)
	StrLen $1 ':\lo'          ; $1 = Word leght (4)
	; StrCpy $R0 $R1 $1 $0    ; $R0 = :\lo
 
	end:
SectionEnd

Example (With errorlevel output):

Section
	${WordFind} "[string]" "[delimiter]" "E[options]" $R0
 
	IfErrors 0 end
	StrCmp $R0 1 0 +2       ; errorlevel 1?
	MessageBox MB_OK 'delimiter not found' IDOK end
	StrCmp $R0 2 0 +2       ; errorlevel 2?
	MessageBox MB_OK 'no such word number' IDOK end
	StrCmp $R0 3 0 +2       ; errorlevel 3?
	MessageBox MB_OK 'syntax error'
 
	end:
SectionEnd

Example (Without errorlevel output):

Section
	${WordFind} "C:\io.sys C:\logo.sys" "_" "+1" $R0
 
	; $R0="C:\io.sys C:\logo.sys" (error: delimiter "_" not found)
SectionEnd

Example (If found):

Section
	${WordFind} "C:\io.sys C:\logo.sys" ":\lo" "E+1{" $R0
 
	IfErrors notfound found
	found:
	MessageBox MB_OK 'Found' IDOK end
	notfound:
	MessageBox MB_OK 'Not found'
 
	end:
SectionEnd

Example (If found 2):

Section
	${WordFind} "C:\io.sys C:\logo.sys" ":\lo" "+1{" $R0
 
	StrCmp $R0 "C:\io.sys C:\logo.sys" notfound found        ; error?
	found:
	MessageBox MB_OK 'Found' IDOK end
	notfound:
	MessageBox MB_OK 'Not found'
 
	end:
SectionEnd

Example (To accept one word in string if delimiter not found):

Section
	StrCpy $0 'OneWord'
	StrCpy $1 1
 
	loop:
	${WordFind} "$0" " " "E+$1" $R0
	IfErrors 0 code
	StrCmp $1$R0 11 0 error
	StrCpy $R0 $0
	goto end
 
	code:
	; ...
	IntOp $1 $1 + 1
	goto loop
 
	error:
	StrCpy $1 ''
	StrCpy $R0 ''
 
	end:
	; $R0="OneWord"
SectionEnd

Function Code

Function WordFind
	!define WordFind `!insertmacro WordFindCall`
 
	!macro WordFindCall _STRING _DELIMITER _OPTION _RESULT
		Push `${_STRING}`
		Push `${_DELIMITER}`
		Push `${_OPTION}`
		Call WordFind
		Pop ${_RESULT}
	!macroend
 
	Exch $1
	Exch
	Exch $0
	Exch
	Exch 2
	Exch $R0
	Exch 2
	Push $2
	Push $3
	Push $4
	Push $5
	Push $6
	Push $7
	Push $8
	Push $9
	Push $R1
	ClearErrors
 
	StrCpy $9 ''
	StrCpy $2 $1 1
	StrCpy $1 $1 '' 1
	StrCmp $2 'E' 0 +3
	StrCpy $9 E
	goto -4
 
	StrCpy $3 ''
	StrCmp $2 '+' +6
	StrCmp $2 '-' +5
	StrCmp $2 '/' restart
	StrCmp $2 '#' restart
	StrCmp $2 '*' restart
	goto error3
 
	StrCpy $4 $1 1 -1
	StrCmp $4 '*' +4
	StrCmp $4 '}' +3
	StrCmp $4 '{' +2
	goto +4
	StrCpy $1 $1 -1
	StrCpy $3 '$4$3'
	goto -7
	StrCmp $3 '*' error3
	StrCmp $3 '**' error3
	StrCmp $3 '}{' error3
	IntOp $1 $1 + 0
	StrCmp $1 0 error2
 
	restart:
	StrCmp $R0 '' error1
	StrCpy $4 0
	StrCpy $5 0
	StrCpy $6 0
	StrLen $7 $0
	goto loop
 
	preloop:
	IntOp $6 $6 + 1
 
	loop:
	StrCpy $8 $R0 $7 $6
	StrCmp $8$5 0 error1
	StrCmp $8 '' +2
	StrCmp $8 $0 +5 preloop
	StrCmp $3 '{' minus
	StrCmp $3 '}' minus
	StrCmp $2 '*' minus
	StrCmp $5 $6 minus +5
	StrCmp $3 '{' +4
	StrCmp $3 '}' +3
	StrCmp $2 '*' +2
	StrCmp $5 $6 nextword
	IntOp $4 $4 + 1
	StrCmp $2$4 +$1 plus
	StrCmp $2 '/' 0 nextword
	IntOp $8 $6 - $5
	StrCpy $8 $R0 $8 $5
	StrCmp $1 $8 0 nextword
	StrCpy $R1 $4
	goto end
	nextword:
	IntOp $6 $6 + $7
	StrCpy $5 $6
	goto loop
 
	minus:
	StrCmp $2 '-' 0 sum
	StrCpy $2 '+'
	IntOp $1 $4 - $1
	IntOp $1 $1 + 1
	IntCmp $1 0 error2 error2 restart
	sum:
	StrCmp $2 '#' 0 sumdelim
	StrCpy $R1 $4
	goto end
	sumdelim:
	StrCmp $2 '*' 0 error2
	StrCpy $R1 $4
	goto end
 
	plus:
	StrCmp $3 '' 0 +4
	IntOp $6 $6 - $5
	StrCpy $R1 $R0 $6 $5
	goto end
	StrCmp $3 '{' 0 +3
	StrCpy $R1 $R0 $6
	goto end
	StrCmp $3 '}' 0 +4
	IntOp $6 $6 + $7
	StrCpy $R1 $R0 '' $6
	goto end
	StrCmp $3 '{*' +2
	StrCmp $3 '*{' 0 +3
	StrCpy $R1 $R0 $6
	goto end
	StrCmp $3 '*}' +2
	StrCmp $3 '}*' 0 +3
	StrCpy $R1 $R0 '' $5
	goto end
	StrCmp $3 '}}' 0 +3
	StrCpy $R1 $R0 '' $6
	goto end
	StrCmp $3 '{{' 0 +3
	StrCpy $R1 $R0 $5
	goto end
	StrCmp $3 '{}' 0 error3
	StrLen $3 $R0
	StrCmp $3 $6 0 +3
	StrCpy $0 ''
	goto +2
	IntOp $6 $6 + $7
	StrCpy $8 $R0 '' $6
	StrCmp $4$8 1 +6
	StrCmp $4 1 +2 +7
	IntOp $6 $6 + $7
	StrCpy $3 $R0 $7 $6
	StrCmp $3 '' +2
	StrCmp $3 $0 -3 +3
	StrCpy $R1 ''
	goto end
	StrCmp $5 0 0 +3
	StrCpy $0 ''
	goto +2
	IntOp $5 $5 - $7
	StrCpy $3 $R0 $5
	StrCpy $R1 '$3$0$8'
	goto end
 
	error3:
	StrCpy $R1 3
	goto error
	error2:
	StrCpy $R1 2
	goto error
	error1:
	StrCpy $R1 1
	error:
	StrCmp $9 'E' 0 +3
	SetErrors
 
	end:
	StrCpy $R0 $R1
 
	Pop $R1
	Pop $9
	Pop $8
	Pop $7
	Pop $6
	Pop $5
	Pop $4
	Pop $3
	Pop $2
	Pop $1
	Pop $0
	Exch $R0
FunctionEnd