latest StrFunc example and readme

git-svn-id: https://svn.code.sf.net/p/nsis/code/NSIS/trunk@3578 212acab6-be3b-0410-9dea-997c60f758d6
This commit is contained in:
kichik 2004-06-25 20:00:50 +00:00
parent 5d8517c328
commit da90827244
2 changed files with 276 additions and 29 deletions

View file

@ -1,27 +1,70 @@
Name "NSIS StrFunc Example"
OutFile "StrFunc.exe"
ShowInstDetails show
ShowUninstDetails show
XPStyle on
!include "StrFunc.nsh"
# declare used functions
# Declare used functions
${StrCase}
${StrClbGet}
${StrClbSet}
${StrIOToNSIS}
${StrLoc}
${StrLowerCase}
${StrNSISToIO}
${StrRep}
${StrStr}
${StrStrAdv}
${StrTok}
${StrTrimNewLines}
${StrUpperCase}
${StrSort}
${UnStrFunc}
${UnStrCase}
${UnStrClbGet}
${UnStrClbSet}
${UnStrIOToNSIS}
${UnStrLoc}
${UnStrNSISToIO}
${UnStrRep}
${UnStrStr}
${UnStrStrAdv}
${UnStrTok}
${UnStrTrimNewLines}
${UnStrSort}
Section
# test clipboard functions
# Test case conversion
${StrCase} $0 "This is just an example. However this can be useful." ""
StrCmp $0 "This is just an example. However this can be useful." 0 strcaseerror
${StrCase} $0 "This is just an example. However this can be useful." "Sentence Case"
StrCmp $0 "This is just an example. However this can be useful." 0 strcaseerror
${StrCase} $0 "this is just an example. however this can be useful." "Lower Case"
StrCmp $0 "this is just an example. however this can be useful." 0 strcaseerror
${StrCase} $0 "THIS IS JUST AN EXAMPLE. HOWEVER THIS CAN BE USEFUL." "Upper Case"
StrCmp $0 "THIS IS JUST AN EXAMPLE. HOWEVER THIS CAN BE USEFUL." 0 strcaseerror
${StrCase} $0 "This Is Just An Example. However This Can Be Useful." "Title Case"
StrCmp $0 "This Is Just An Example. However This Can Be Useful." 0 strcaseerror
${StrCase} $0 "123456789!@#%^&*()-_=+[]{};:,./<>?" "Setence Case"
StrCmp $0 "123456789!@#%^&*()-_=+[]{};:,./<>?" 0 strcaseerror
${StrCase} $0 "123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ!@#%^&*()abcdefghijklmnopqrstuvwxyz-_=+[]{};:,./<>?" "Setence Case"
StrCmp $0 "123456789Abcdefghijklmnopqrstuvwxyz!@#%^&*()Abcdefghijklmnopqrstuvwxyz-_=+[]{};:,./<>?" 0 strcaseerror
${StrCase} $0 "what about taking a shower tomorrow? it's late to do so now! try to sleep now. Good Night!" "Setence Case"
StrCmp $0 "What about taking a shower tomorrow? It's late to do so now! Try to sleep now. Good night!" 0 strcaseerror
DetailPrint "PASSED StrCase test"
Goto +2
strcaseerror:
DetailPrint "FAILED StrCase test"
# Test clipboard functions
${StrClbSet} "StrFunc clipboard test"
${StrClbGet} $0
StrCmp $0 "StrFunc clipboard test" +3
@ -29,7 +72,7 @@ Section
Goto +2
DetailPrint "PASSED StrClbGet/StrClbSet test"
# test IO functions
# Test IO functions
!macro testio str
${StrNSISToIO} $0 "${str}"
${StrIOToNSIS} $0 $0
@ -48,7 +91,7 @@ Section
ioerror:
DetailPrint "FAILED StrNSISToIO/StrIOToNSIS test"
# test string search functions
# Test string search functions
${StrLoc} $0 "This is just an example" "just" "<"
StrCmp $0 "11" 0 strlocerror
${StrLoc} $0 a abc <
@ -98,7 +141,7 @@ strstrerror:
${StrStrAdv} $0 "abcabcabc" "abc" ">" "<" "1" "1"
StrCmp $0 "abcabc" 0 strstradverror
${StrStrAdv} $0 "abcabcabc" "abc" ">" "<" "0" "1"
StrCmp $0 "abcabc" 0 strstradverror
StrCmp $0 "abc" 0 strstradverror
${StrStrAdv} $0 "abcabcabc" "abc" "<" "<" "1" "0"
StrCmp $0 "abcabcabc" 0 strstradverror
${StrStrAdv} $0 "abcabcabc" "abc" "<" "<" "0" "0"
@ -112,7 +155,7 @@ strstrerror:
strstradverror:
DetailPrint "FAILED StrStrAdv test"
# test string replacement
# Test string replacement
${StrRep} $0 "This is just an example" "an" "one"
StrCmp $0 "This is just one example" 0 strreperror
${StrRep} $0 "test... test... 1 2 3..." "test" "testing"
@ -132,7 +175,7 @@ strstradverror:
strreperror:
DetailPrint "FAILED StrRep test"
# test sorting
# Test sorting
${StrSort} $0 "This is just an example" " just" "" "ple" "0" "0"
StrCmp $0 "This is an exam" 0 strsorterror
${StrSort} $0 "This is just an example" "j" " " " " "0" "1"
@ -176,15 +219,7 @@ strreperror:
strsorterror:
DetailPrint "FAILED StrSort test"
# test lower/upper case
${StrLowerCase} $0 "abcefghijklmnopqrstuvwxyz"
${StrUpperCase} $0 $0
StrCmp $0 "abcefghijklmnopqrstuvwxyz" +3
DetailPrint "FAILED StrLowerCase/StrUpperCase test"
Goto +2
DetailPrint "PASSED StrLowerCase/StrUpperCase test"
# test tokenizer
# Test tokenizer
${StrTok} $0 "This is, or is not, just an example" " ," "5" "1"
StrCmp $0 "not" 0 strtokerror
${StrTok} $0 "This is, or is not, just an example" " ," "5" "0"
@ -202,11 +237,227 @@ strsorterror:
strtokerror:
DetailPrint "FAILED StrTok test"
# test trim new lines
# Test trim new lines
${StrTrimNewLines} $0 "$\r$\ntest$\r$\ntest$\r$\n"
StrCmp $0 "$\r$\ntest$\r$\ntest" +3
DetailPrint "FAILED StrTrimNewLines test"
Goto +2
DetailPrint "PASSED StrTrimNewLines test"
SectionEnd
WriteUninstaller $EXEDIR\UnStrFunc.exe
Exec $EXEDIR\UnStrFunc.exe
SectionEnd
Section Uninstall
# Test case conversion
${UnStrCase} $0 "This is just an example. However this can be useful." ""
StrCmp $0 "This is just an example. However this can be useful." 0 strcaseerror
${UnStrCase} $0 "This is just an example. However this can be useful." "Sentence Case"
StrCmp $0 "This is just an example. However this can be useful." 0 strcaseerror
${UnStrCase} $0 "this is just an example. however this can be useful." "Lower Case"
StrCmp $0 "this is just an example. however this can be useful." 0 strcaseerror
${UnStrCase} $0 "THIS IS JUST AN EXAMPLE. HOWEVER THIS CAN BE USEFUL." "Upper Case"
StrCmp $0 "THIS IS JUST AN EXAMPLE. HOWEVER THIS CAN BE USEFUL." 0 strcaseerror
${UnStrCase} $0 "This Is Just An Example. However This Can Be Useful." "Title Case"
StrCmp $0 "This Is Just An Example. However This Can Be Useful." 0 strcaseerror
${UnStrCase} $0 "123456789!@#%^&*()-_=+[]{};:,./<>?" "Setence Case"
StrCmp $0 "123456789!@#%^&*()-_=+[]{};:,./<>?" 0 strcaseerror
${UnStrCase} $0 "123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ!@#%^&*()abcdefghijklmnopqrstuvwxyz-_=+[]{};:,./<>?" "Setence Case"
StrCmp $0 "123456789Abcdefghijklmnopqrstuvwxyz!@#%^&*()Abcdefghijklmnopqrstuvwxyz-_=+[]{};:,./<>?" 0 strcaseerror
${UnStrCase} $0 "what about taking a shower tomorrow? it's late to do so now! try to sleep now. Good Night!" "Setence Case"
StrCmp $0 "What about taking a shower tomorrow? It's late to do so now! Try to sleep now. Good night!" 0 strcaseerror
DetailPrint "PASSED StrCase test"
Goto +2
strcaseerror:
DetailPrint "FAILED StrCase test"
# Test clipboard functions
${UnStrClbSet} "StrFunc clipboard test"
${UnStrClbGet} $0
StrCmp $0 "StrFunc clipboard test" +3
DetailPrint "FAILED StrClbGet/StrClbSet test"
Goto +2
DetailPrint "PASSED StrClbGet/StrClbSet test"
# Test IO functions
!macro untestio str
${UnStrNSISToIO} $0 "${str}"
${UnStrIOToNSIS} $0 $0
StrCmp $0 "${str}" 0 ioerror
!macroend
!insertmacro untestio "$\rtest$\n"
!insertmacro untestio "test$\n"
!insertmacro untestio "$\rtest"
!insertmacro untestio "test"
!insertmacro untestio "$\r\$\t$\n"
!insertmacro untestio "$\r \ $\t $\n $$"
!insertmacro untestio ""
!insertmacro untestio " "
DetailPrint "PASSED StrNSISToIO/StrIOToNSIS test"
Goto +2
ioerror:
DetailPrint "FAILED StrNSISToIO/StrIOToNSIS test"
# Test string search functions
${UnStrLoc} $0 "This is just an example" "just" "<"
StrCmp $0 "11" 0 strlocerror
${UnStrLoc} $0 a abc <
StrCmp $0 "" 0 strlocerror
${UnStrLoc} $0 a abc >
StrCmp $0 "" 0 strlocerror
${UnStrLoc} $0 abc a >
StrCmp $0 "0" 0 strlocerror
${UnStrLoc} $0 abc b >
StrCmp $0 "1" 0 strlocerror
${UnStrLoc} $0 abc c >
StrCmp $0 "2" 0 strlocerror
${UnStrLoc} $0 abc a <
StrCmp $0 "2" 0 strlocerror
${UnStrLoc} $0 abc b <
StrCmp $0 "1" 0 strlocerror
${UnStrLoc} $0 abc c <
StrCmp $0 "0" 0 strlocerror
${UnStrLoc} $0 abc d <
StrCmp $0 "" 0 strlocerror
DetailPrint "PASSED StrLoc test"
Goto +2
strlocerror:
DetailPrint "FAILED StrLoc test"
${UnStrStr} $0 "abcefghijklmnopqrstuvwxyz" "g"
StrCmp $0 "ghijklmnopqrstuvwxyz" 0 strstrerror
${UnStrStr} $0 "abcefghijklmnopqrstuvwxyz" "ga"
StrCmp $0 "" 0 strstrerror
${UnStrStr} $0 "abcefghijklmnopqrstuvwxyz" ""
StrCmp $0 "abcefghijklmnopqrstuvwxyz" 0 strstrerror
${UnStrStr} $0 "a" "abcefghijklmnopqrstuvwxyz"
StrCmp $0 "" 0 strstrerror
DetailPrint "PASSED StrStr test"
Goto +2
strstrerror:
DetailPrint "FAILED StrStr test"
${UnStrStrAdv} $0 "abcabcabc" "a" ">" ">" "1" "0"
StrCmp $0 "abcabcabc" 0 strstradverror
${UnStrStrAdv} $0 "abcabcabc" "a" ">" ">" "1" "1"
StrCmp $0 "abcabc" 0 strstradverror
${UnStrStrAdv} $0 "abcabcabc" "a" ">" ">" "1" "2"
StrCmp $0 "abc" 0 strstradverror
${UnStrStrAdv} $0 "abcabcabc" "a" ">" ">" "1" "3"
StrCmp $0 "" 0 strstradverror
${UnStrStrAdv} $0 "abcabcabc" "abc" ">" "<" "1" "1"
StrCmp $0 "abcabc" 0 strstradverror
${UnStrStrAdv} $0 "abcabcabc" "abc" ">" "<" "0" "1"
StrCmp $0 "abc" 0 strstradverror
${UnStrStrAdv} $0 "abcabcabc" "abc" "<" "<" "1" "0"
StrCmp $0 "abcabcabc" 0 strstradverror
${UnStrStrAdv} $0 "abcabcabc" "abc" "<" "<" "0" "0"
StrCmp $0 "abcabc" 0 strstradverror
${UnStrStrAdv} $0 "abcabcabc" "abc" "<" ">" "0" "0"
StrCmp $0 "" 0 strstradverror
${UnStrStrAdv} $0 "abcabcabc" "abc" "<" ">" "0" "1"
StrCmp $0 "abc" 0 strstradverror
DetailPrint "PASSED StrStrAdv test"
Goto +2
strstradverror:
DetailPrint "FAILED StrStrAdv test"
# Test string replacement
${UnStrRep} $0 "This is just an example" "an" "one"
StrCmp $0 "This is just one example" 0 strreperror
${UnStrRep} $0 "test... test... 1 2 3..." "test" "testing"
StrCmp $0 "testing... testing... 1 2 3..." 0 strreperror
${UnStrRep} $0 "" "test" "testing"
StrCmp $0 "" 0 strreperror
${UnStrRep} $0 "test" "test" "testing"
StrCmp $0 "testing" 0 strreperror
${UnStrRep} $0 "test" "test" ""
StrCmp $0 "" 0 strreperror
${UnStrRep} $0 "test" "" "abc"
StrCmp $0 "test" 0 strreperror
${UnStrRep} $0 "test" "" ""
StrCmp $0 "test" 0 strreperror
DetailPrint "PASSED StrRep test"
Goto +2
strreperror:
DetailPrint "FAILED StrRep test"
# Test sorting
${UnStrSort} $0 "This is just an example" " just" "" "ple" "0" "0"
StrCmp $0 "This is an exam" 0 strsorterror
${UnStrSort} $0 "This is just an example" "j" " " " " "0" "1"
StrCmp $0 "just" 0 strsorterror
${UnStrSort} $0 "This is just an example" "j" "" "" "0" "1"
StrCmp $0 "This is just an example" 0 strsorterror
${UnStrSort} $0 "This is just an example" "us" " " "" "0" "1"
StrCmp $0 "just an example" 0 strsorterror
${UnStrSort} $0 "This is just an example" "u" "" " " "0" "1"
StrCmp $0 "This is just" 0 strsorterror
${UnStrSort} $0 "This is just an example" "just" " " " " "0" "1"
StrCmp $0 "just" 0 strsorterror
${UnStrSort} $0 "This is just an example" "t" " " " " "0" "1"
StrCmp $0 "This" 0 strsorterror
${UnStrSort} $0 "This is just an example" "le" " " " " "0" "1"
StrCmp $0 "example" 0 strsorterror
${UnStrSort} $0 "This is just an example" "le" " " " " "1" "0"
StrCmp $0 " examp" 0 strsorterror
${UnStrSort} $0 "an error has occured" "e" " " " " "0" "1"
StrCmp $0 "error" 0 strsorterror
${UnStrSort} $0 "" "something" " " " " "0" "1"
StrCmp $0 "" 0 strsorterror
${UnStrSort} $0 "This is just an example" "j" " " " " "1" "1"
StrCmp $0 " just " 0 strsorterror
${UnStrSort} $0 "This is just an example" "j" " " " " "1" "0"
StrCmp $0 " ust " 0 strsorterror
${UnStrSort} $0 "This is just an example" "j" "" "" "1" "0"
StrCmp $0 "This is ust an example" 0 strsorterror
${UnStrSort} $0 "This is just an example" "us" " " "" "1" "0"
StrCmp $0 " jt an example" 0 strsorterror
${UnStrSort} $0 "This is just an example" "u" "" " " "1" "0"
StrCmp $0 "This is jst " 0 strsorterror
${UnStrSort} $0 "This is just an example" "just" " " " " "1" "0"
StrCmp $0 " " 0 strsorterror
${UnStrSort} $0 "an error has occured" "e" " " " " "1" "0"
StrCmp $0 " rror " 0 strsorterror
${UnStrSort} $0 "" "something" " " " " "1" "0"
StrCmp $0 "" 0 strsorterror
DetailPrint "PASSED StrSort test"
Goto +2
strsorterror:
DetailPrint "FAILED StrSort test"
# Test tokenizer
${UnStrTok} $0 "This is, or is not, just an example" " ," "5" "1"
StrCmp $0 "not" 0 strtokerror
${UnStrTok} $0 "This is, or is not, just an example" " ," "5" "0"
StrCmp $0 "is" 0 strtokerror
${UnStrTok} $0 "This is, or is not, just an example" " ," "152" "0"
StrCmp $0 "" 0 strtokerror
${UnStrTok} $0 "This is, or is not, just an example" " ," "0" "0"
StrCmp $0 "example" 0 strtokerror
${UnStrTok} $0 "This is, or is not, just an example" " ," "-1" "0"
StrCmp $0 "example" 0 strtokerror
${UnStrTok} $0 "This is, or is not, just an example" " ," "1" "0"
StrCmp $0 "This" 0 strtokerror
DetailPrint "PASSED StrTok test"
Goto +2
strtokerror:
DetailPrint "FAILED StrTok test"
# Test trim new lines
${UnStrTrimNewLines} $0 "$\r$\ntest$\r$\ntest$\r$\n"
StrCmp $0 "$\r$\ntest$\r$\ntest" +3
DetailPrint "FAILED StrTrimNewLines test"
Goto +2
DetailPrint "PASSED StrTrimNewLines test"
SectionEnd

View file

@ -18,7 +18,7 @@ How to use
useful.
Any time when is mentioned "Default is" means that you can use the value
mentioned or keep blank, the result is the same.
mentioned or keep it blank, the result is the same.
If you want a certain value (e.g. a text) to be language-specific, set a
language string (using LangString) and define $(STRINGNAME) as value.
@ -509,7 +509,7 @@ Comments about functions included and not included
NSISToIO
IOToNSIS
14 functions have not been included
13 functions have not been included
10 were not included because of better functions
6 were not included because of AdvStrTok (called here as StrTok)
First String Part Function
@ -524,8 +524,6 @@ Comments about functions included and not included
1 was not included because of original String Replace Function (called
here as StrRep)
Another String Replace Function
1 was not included because of Number To Text Converter.
Number To String Convertor (Archive original)
2 were not included because isn't useful anymore
Slash <-> Backslash Converter Function
Trim Function
@ -600,10 +598,9 @@ Version History
1.06 - 03/26/2004
- Fixed lots of bugs from faulty basic header file structure relating to
StrNumToStr command.
- StrNumToStr removed due to complex number handling on some languages.
- Fixed the bug where the old string was attached to string returned by
StrCase when $R5 variable was used.
StrCase when $R5 variable was used.
1.05 - 03/17/2004
@ -662,8 +659,7 @@ Functions Credits
-----------------
- Advanced Search in String, Advanced Token String, Localize in String,
String Case, Advanced Sort String, Number To String Convertor made by
Diego Pedroso.
String Case, Advanced Sort String, made by Diego Pedroso.
- Copy to/from clipboard made by Nik Medved.
- StrReplace made by Hendri Adriaens.
- Search in a string, Trim newlines made by Ximon Eighteen.