diff --git a/Examples/StrFunc.nsi b/Examples/StrFunc.nsi index d6900755..09ef3fa3 100644 --- a/Examples/StrFunc.nsi +++ b/Examples/StrFunc.nsi @@ -8,8 +8,7 @@ XPStyle on # Declare used functions ${StrCase} -${StrClbGet} -${StrClbSet} +${StrClb} ${StrIOToNSIS} ${StrLoc} ${StrNSISToIO} @@ -20,11 +19,8 @@ ${StrTok} ${StrTrimNewLines} ${StrSort} -${UnStrFunc} - ${UnStrCase} -${UnStrClbGet} -${UnStrClbSet} +${UnStrClb} ${UnStrIOToNSIS} ${UnStrLoc} ${UnStrNSISToIO} @@ -38,25 +34,27 @@ ${UnStrSort} Section # 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. A very simple one." "" + StrCmp $0 "This is just an example. A very simple one." 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 "THIS IS JUST AN EXAMPLE. A VERY SIMPLE ONE." "S" + StrCmp $0 "This is just an example. A very simple one." 0 strcaseerror + ${StrCase} $0 "This is just an example. A very simple one." "L" + StrCmp $0 "this is just an example. a very simple one." 0 strcaseerror + ${StrCase} $0 "This is just an example. A very simple one." "U" + StrCmp $0 "THIS IS JUST AN EXAMPLE. A VERY SIMPLE ONE." 0 strcaseerror + ${StrCase} $0 "This is just an example. A very simple one." "T" + StrCmp $0 "This Is Just An Example. A Very Simple One." 0 strcaseerror + ${StrCase} $0 "This is just an example. A very simple one." "<>" + StrCmp $0 "tHIS IS JUST AN EXAMPLE. a VERY SIMPLE ONE." 0 strcaseerror - ${StrCase} $0 "123456789!@#%^&*()-_=+[]{};:,./<>?" "Setence Case" + ${StrCase} $0 "123456789!@#%^&*()-_=+[]{};:,./<>?" "S" StrCmp $0 "123456789!@#%^&*()-_=+[]{};:,./<>?" 0 strcaseerror - ${StrCase} $0 "123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ!@#%^&*()abcdefghijklmnopqrstuvwxyz-_=+[]{};:,./<>?" "Setence Case" - StrCmp $0 "123456789Abcdefghijklmnopqrstuvwxyz!@#%^&*()Abcdefghijklmnopqrstuvwxyz-_=+[]{};:,./<>?" 0 strcaseerror + ${StrCase} $0 "123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ!@#%^&*()abcdefghijklmnopqrstuvwxyz-_=+[]{};:,./<>?" "<>" + 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" + ${StrCase} $0 "what about taking a shower tomorrow? it's late to do so now! try to sleep now. Good Night!" "S" 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" @@ -64,13 +62,15 @@ Section strcaseerror: DetailPrint "FAILED StrCase test" - # Test clipboard functions - ${StrClbSet} "StrFunc clipboard test" - ${StrClbGet} $0 - StrCmp $0 "StrFunc clipboard test" +3 - DetailPrint "FAILED StrClbGet/StrClbSet test" - Goto +2 - DetailPrint "PASSED StrClbGet/StrClbSet test" + # Test clipboard function + ${StrClb} $0 "StrFunc clipboard test" ">" + ${StrClb} $0 "" "<" + StrCmp $0 "StrFunc clipboard test" 0 strclberror + + DetailPrint "PASSED StrClb test" + Goto +2 +strclberror: + DetailPrint "FAILED StrClb test" # Test IO functions !macro testio str @@ -130,25 +130,46 @@ strlocerror: strstrerror: DetailPrint "FAILED StrStr test" - ${StrStrAdv} $0 "abcabcabc" "a" ">" ">" "1" "0" + ${StrStrAdv} $0 "abcabcabc" "a" ">" ">" "1" "0" "0" StrCmp $0 "abcabcabc" 0 strstradverror - ${StrStrAdv} $0 "abcabcabc" "a" ">" ">" "1" "1" + ${StrStrAdv} $0 "abcabcabc" "a" ">" ">" "1" "1" "0" StrCmp $0 "abcabc" 0 strstradverror - ${StrStrAdv} $0 "abcabcabc" "a" ">" ">" "1" "2" + ${StrStrAdv} $0 "abcabcabc" "a" ">" ">" "1" "2" "0" StrCmp $0 "abc" 0 strstradverror - ${StrStrAdv} $0 "abcabcabc" "a" ">" ">" "1" "3" + ${StrStrAdv} $0 "abcabcabc" "a" ">" ">" "1" "3" "0" StrCmp $0 "" 0 strstradverror - ${StrStrAdv} $0 "abcabcabc" "abc" ">" "<" "1" "1" + ${StrStrAdv} $0 "abcabcabc" "abc" ">" "<" "1" "1" "0" StrCmp $0 "abcabc" 0 strstradverror - ${StrStrAdv} $0 "abcabcabc" "abc" ">" "<" "0" "1" + ${StrStrAdv} $0 "abcabcabc" "abc" ">" "<" "0" "1" "0" StrCmp $0 "abc" 0 strstradverror - ${StrStrAdv} $0 "abcabcabc" "abc" "<" "<" "1" "0" + ${StrStrAdv} $0 "abcabcabc" "abc" "<" "<" "1" "0" "0" StrCmp $0 "abcabcabc" 0 strstradverror - ${StrStrAdv} $0 "abcabcabc" "abc" "<" "<" "0" "0" + ${StrStrAdv} $0 "abcabcabc" "abc" "<" "<" "0" "0" "0" StrCmp $0 "abcabc" 0 strstradverror - ${StrStrAdv} $0 "abcabcabc" "abc" "<" ">" "0" "0" + ${StrStrAdv} $0 "abcabcabc" "abc" "<" ">" "0" "0" "0" StrCmp $0 "" 0 strstradverror - ${StrStrAdv} $0 "abcabcabc" "abc" "<" ">" "0" "1" + ${StrStrAdv} $0 "abcabcabc" "abc" "<" ">" "0" "1" "0" + StrCmp $0 "abc" 0 strstradverror + + ${StrStrAdv} $0 "ABCabcabc" "a" ">" ">" "1" "0" "1" + StrCmp $0 "abcabc" 0 strstradverror + ${StrStrAdv} $0 "ABCabcabc" "a" ">" ">" "1" "1" "1" + StrCmp $0 "abc" 0 strstradverror + ${StrStrAdv} $0 "ABCabcabc" "a" ">" ">" "1" "2" "1" + StrCmp $0 "" 0 strstradverror + ${StrStrAdv} $0 "ABCabcabc" "a" ">" ">" "1" "3" "1" + StrCmp $0 "" 0 strstradverror + ${StrStrAdv} $0 "ABCabcabc" "abc" ">" "<" "1" "1" "1" + StrCmp $0 "ABCabcabc" 0 strstradverror + ${StrStrAdv} $0 "ABCabcabc" "abc" ">" "<" "0" "1" "1" + StrCmp $0 "ABCabc" 0 strstradverror + ${StrStrAdv} $0 "ABCabcabc" "abc" "<" "<" "1" "0" "1" + StrCmp $0 "ABCabcabc" 0 strstradverror + ${StrStrAdv} $0 "ABCabcabc" "abc" "<" "<" "0" "0" "1" + StrCmp $0 "ABCabc" 0 strstradverror + ${StrStrAdv} $0 "ABCabcabc" "abc" "<" ">" "0" "0" "1" + StrCmp $0 "" 0 strstradverror + ${StrStrAdv} $0 "ABCabcabc" "abc" "<" ">" "0" "1" "1" StrCmp $0 "abc" 0 strstradverror DetailPrint "PASSED StrStrAdv test" Goto +2 @@ -253,25 +274,27 @@ 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. A very simple one." "" + StrCmp $0 "This is just an example. A very simple one." 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 "THIS IS JUST AN EXAMPLE. A VERY SIMPLE ONE." "S" + StrCmp $0 "This is just an example. A very simple one." 0 strcaseerror + ${UnStrCase} $0 "This is just an example. A very simple one." "L" + StrCmp $0 "this is just an example. a very simple one." 0 strcaseerror + ${UnStrCase} $0 "This is just an example. A very simple one." "U" + StrCmp $0 "THIS IS JUST AN EXAMPLE. A VERY SIMPLE ONE." 0 strcaseerror + ${UnStrCase} $0 "This is just an example. A very simple one." "T" + StrCmp $0 "This Is Just An Example. A Very Simple One." 0 strcaseerror + ${UnStrCase} $0 "This is just an example. A very simple one." "<>" + StrCmp $0 "tHIS IS JUST AN EXAMPLE. a VERY SIMPLE ONE." 0 strcaseerror - ${UnStrCase} $0 "123456789!@#%^&*()-_=+[]{};:,./<>?" "Setence Case" + ${UnStrCase} $0 "123456789!@#%^&*()-_=+[]{};:,./<>?" "S" StrCmp $0 "123456789!@#%^&*()-_=+[]{};:,./<>?" 0 strcaseerror - ${UnStrCase} $0 "123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ!@#%^&*()abcdefghijklmnopqrstuvwxyz-_=+[]{};:,./<>?" "Setence Case" - StrCmp $0 "123456789Abcdefghijklmnopqrstuvwxyz!@#%^&*()Abcdefghijklmnopqrstuvwxyz-_=+[]{};:,./<>?" 0 strcaseerror + ${UnStrCase} $0 "123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ!@#%^&*()abcdefghijklmnopqrstuvwxyz-_=+[]{};:,./<>?" "<>" + 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" + ${UnStrCase} $0 "what about taking a shower tomorrow? it's late to do so now! try to sleep now. Good Night!" "S" 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" @@ -279,13 +302,15 @@ Section Uninstall 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 clipboard function + ${UnStrClb} $0 "StrFunc clipboard test" ">" + ${UnStrClb} $0 "" "<" + StrCmp $0 "StrFunc clipboard test" 0 strclberror + + DetailPrint "PASSED StrClb test" + Goto +2 +strclberror: + DetailPrint "FAILED StrClb test" # Test IO functions !macro untestio str @@ -345,25 +370,46 @@ strlocerror: strstrerror: DetailPrint "FAILED StrStr test" - ${UnStrStrAdv} $0 "abcabcabc" "a" ">" ">" "1" "0" + ${UnStrStrAdv} $0 "abcabcabc" "a" ">" ">" "1" "0" "0" StrCmp $0 "abcabcabc" 0 strstradverror - ${UnStrStrAdv} $0 "abcabcabc" "a" ">" ">" "1" "1" + ${UnStrStrAdv} $0 "abcabcabc" "a" ">" ">" "1" "1" "0" StrCmp $0 "abcabc" 0 strstradverror - ${UnStrStrAdv} $0 "abcabcabc" "a" ">" ">" "1" "2" + ${UnStrStrAdv} $0 "abcabcabc" "a" ">" ">" "1" "2" "0" StrCmp $0 "abc" 0 strstradverror - ${UnStrStrAdv} $0 "abcabcabc" "a" ">" ">" "1" "3" + ${UnStrStrAdv} $0 "abcabcabc" "a" ">" ">" "1" "3" "0" StrCmp $0 "" 0 strstradverror - ${UnStrStrAdv} $0 "abcabcabc" "abc" ">" "<" "1" "1" + ${UnStrStrAdv} $0 "abcabcabc" "abc" ">" "<" "1" "1" "0" StrCmp $0 "abcabc" 0 strstradverror - ${UnStrStrAdv} $0 "abcabcabc" "abc" ">" "<" "0" "1" + ${UnStrStrAdv} $0 "abcabcabc" "abc" ">" "<" "0" "1" "0" StrCmp $0 "abc" 0 strstradverror - ${UnStrStrAdv} $0 "abcabcabc" "abc" "<" "<" "1" "0" + ${UnStrStrAdv} $0 "abcabcabc" "abc" "<" "<" "1" "0" "0" StrCmp $0 "abcabcabc" 0 strstradverror - ${UnStrStrAdv} $0 "abcabcabc" "abc" "<" "<" "0" "0" + ${UnStrStrAdv} $0 "abcabcabc" "abc" "<" "<" "0" "0" "0" StrCmp $0 "abcabc" 0 strstradverror - ${UnStrStrAdv} $0 "abcabcabc" "abc" "<" ">" "0" "0" + ${UnStrStrAdv} $0 "abcabcabc" "abc" "<" ">" "0" "0" "0" StrCmp $0 "" 0 strstradverror - ${UnStrStrAdv} $0 "abcabcabc" "abc" "<" ">" "0" "1" + ${UnStrStrAdv} $0 "abcabcabc" "abc" "<" ">" "0" "1" "0" + StrCmp $0 "abc" 0 strstradverror + + ${UnStrStrAdv} $0 "ABCabcabc" "a" ">" ">" "1" "0" "1" + StrCmp $0 "abcabc" 0 strstradverror + ${UnStrStrAdv} $0 "ABCabcabc" "a" ">" ">" "1" "1" "1" + StrCmp $0 "abc" 0 strstradverror + ${UnStrStrAdv} $0 "ABCabcabc" "a" ">" ">" "1" "2" "1" + StrCmp $0 "" 0 strstradverror + ${UnStrStrAdv} $0 "ABCabcabc" "a" ">" ">" "1" "3" "1" + StrCmp $0 "" 0 strstradverror + ${UnStrStrAdv} $0 "ABCabcabc" "abc" ">" "<" "1" "1" "1" + StrCmp $0 "ABCabcabc" 0 strstradverror + ${UnStrStrAdv} $0 "ABCabcabc" "abc" ">" "<" "0" "1" "1" + StrCmp $0 "ABCabc" 0 strstradverror + ${UnStrStrAdv} $0 "ABCabcabc" "abc" "<" "<" "1" "0" "1" + StrCmp $0 "ABCabcabc" 0 strstradverror + ${UnStrStrAdv} $0 "ABCabcabc" "abc" "<" "<" "0" "0" "1" + StrCmp $0 "ABCabc" 0 strstradverror + ${UnStrStrAdv} $0 "ABCabcabc" "abc" "<" ">" "0" "0" "1" + StrCmp $0 "" 0 strstradverror + ${UnStrStrAdv} $0 "ABCabcabc" "abc" "<" ">" "0" "1" "1" StrCmp $0 "abc" 0 strstradverror DetailPrint "PASSED StrStrAdv test" Goto +2 @@ -460,4 +506,3 @@ strtokerror: DetailPrint "PASSED StrTrimNewLines test" SectionEnd - diff --git a/Include/StrFunc.nsh b/Include/StrFunc.nsh index 7a9527bb..73694d89 100644 --- a/Include/StrFunc.nsh +++ b/Include/StrFunc.nsh @@ -1,1390 +1,1412 @@ /* - -Functions Header File for NSIS - -StrFunc.nsh -This file contains functions for string manipulation for NSIS - -by Diego Pedroso (aka deguix) - +o-----------------------------------------------------------------------------o +|String Functions Header File 1.07 | +(-----------------------------------------------------------------------------) +| By deguix / A Header file for NSIS 2.01 | +| -------------------------------| +| | +| This header file contains NSIS functions for string manipulation. | +o-----------------------------------------------------------------------------o */ -!ifndef MUI_VERBOSE - !define MUI_VERBOSE 3 +!verbose push +!verbose 3 +!ifndef STRFUNC_VERBOSITY + !define STRFUNC_VERBOSITY 3 !endif +!define _STRFUNC_VERBOSITY ${STRFUNC_VERBOSITY} +!undef STRFUNC_VERBOSITY +!verbose ${_STRFUNC_VERBOSITY} -!echo `$\r$\n----------------------------------------------------------------------$\r$\nNSIS String Functions Header File 1.06 - © 2004 Diego Pedroso$\r$\n----------------------------------------------------------------------$\r$\n$\r$\n` +!include LogicLib.nsh -!define StrCase `!insertmacro FUNCTION_STRING_StrCase` -!define StrClbGet `!insertmacro FUNCTION_STRING_StrClbGet` -!define StrClbSet `!insertmacro FUNCTION_STRING_StrClbSet` -!define StrIOToNSIS `!insertmacro FUNCTION_STRING_StrIOToNSIS` -!define StrLoc `!insertmacro FUNCTION_STRING_StrLoc` -!define StrNSISToIO `!insertmacro FUNCTION_STRING_StrNSISToIO` -!define StrRep `!insertmacro FUNCTION_STRING_StrRep` -!define StrSort `!insertmacro FUNCTION_STRING_StrSort` -!define StrStr `!insertmacro FUNCTION_STRING_StrStr` -!define StrStrAdv `!insertmacro FUNCTION_STRING_StrStrAdv` -!define StrTok `!insertmacro FUNCTION_STRING_StrTok` -!define StrTrimNewLines `!insertmacro FUNCTION_STRING_StrTrimNewLines` +!ifndef STRFUNC -!define UnStrFunc `!insertmacro FUNCTION_STRING_UninstSupport` + ;Header File Identification -!macro FUNCTION_STRING_UninstSupport + !define STRFUNC `String Functions Header File` + !define STRFUNC_SHORT `StrFunc` + !define STRFUNC_CREDITS `2004 Diego Pedroso` - !define FUNCTION_STRING_UninstSupport + ;Header File Version - !define UnStrCase `!insertmacro FUNCTION_STRING_StrCase` - !define UnStrClbGet `!insertmacro FUNCTION_STRING_StrClbGet` - !define UnStrClbSet `!insertmacro FUNCTION_STRING_StrClbSet` - !define UnStrIOToNSIS `!insertmacro FUNCTION_STRING_StrIOToNSIS` - !define UnStrLoc `!insertmacro FUNCTION_STRING_StrLoc` - !define UnStrNSISToIO `!insertmacro FUNCTION_STRING_StrNSISToIO` - !define UnStrRep `!insertmacro FUNCTION_STRING_StrRep` - !define UnStrSort `!insertmacro FUNCTION_STRING_StrSort` - !define UnStrStr `!insertmacro FUNCTION_STRING_StrStr` - !define UnStrStrAdv `!insertmacro FUNCTION_STRING_StrStrAdv` - !define UnStrTok `!insertmacro FUNCTION_STRING_StrTok` - !define UnStrTrimNewLines `!insertmacro FUNCTION_STRING_StrTrimNewLines` + !define STRFUNC_VERMAJ 1 + !define STRFUNC_VERMED 07 + ;!define STRFUNC_VERMIN 0 + ;!define STRFUNC_VERBLD 0 -!macroend + !define STRFUNC_VER `${STRFUNC_VERMAJ}.${STRFUNC_VERMED}` -# Function StrCase -################ + ;Header File Init Message Prefix and Postfix -!macro FUNCTION_STRING_StrCase + !define STRFUNC_INITMSGPRE `----------------------------------------------------------------------$\r$\n` + !define STRFUNC_INITMSGPOST `$\r$\n----------------------------------------------------------------------$\r$\n` - !echo `$\r$\n----------------------------------------------------------------------$\r$\nChange Case String Function - © 2004 Diego Pedroso$\r$\n----------------------------------------------------------------------$\r$\n$\r$\n` + ;Header File Init Message - !ifdef FUNCTION_STRING_UninstSupport + !verbose push + !verbose 4 + !echo `${STRFUNC_INITMSGPRE}NSIS ${STRFUNC} ${STRFUNC_VER} - © ${STRFUNC_CREDITS}${STRFUNC_INITMSGPOST}` + !verbose pop + + ;Header File Function Init Message Prefix and Postfix + + !define STRFUNC_FUNCMSGPRE `` + !define STRFUNC_FUNCMSGPOST `` + + ;Header File Function Macros + + !macro STRFUNC_DEFFUNC Name + !define `${Name}` `!insertmacro FUNCTION_STRING_${Name}` + !define `Un${Name}` `!insertmacro FUNCTION_STRING_Un${Name}` + !macroend + + !macro STRFUNC_FUNC ShortName Credits + !verbose push + !verbose 4 + + !ifndef `Un${ShortName}` + !echo `${STRFUNC_FUNCMSGPRE}$ {Un${ShortName}} - © ${Credits}${STRFUNC_FUNCMSGPOST}` + !verbose pop + !define `Un${ShortName}` `!insertmacro FUNCTION_STRING_Un${ShortName}_Call` + Function `un.${ShortName}` + !else + !echo `${STRFUNC_FUNCMSGPRE}$ {${ShortName}} - © ${Credits}${STRFUNC_FUNCMSGPOST}` + !verbose pop + !undef `${ShortName}` + !define `${ShortName}` `!insertmacro FUNCTION_STRING_${ShortName}_Call` + Function `${ShortName}` + !endif + !macroend + + ;Function Names Startup Definition + + !insertmacro STRFUNC_DEFFUNC StrCase + !macro `FUNCTION_STRING_UnStrCase` !undef UnStrCase - !define UnStrCase `!insertmacro FUNCTION_STRING_UnStrCase_Call` - Function un.StrCase - !else - !undef StrCase - !define StrCase `!insertmacro FUNCTION_STRING_StrCase_Call` - Function StrCase - !endif - - Exch $R0 - Exch - Exch $R1 - Push $R2 - Push $R3 - Push $R4 - Push $R5 - Push $R6 - - - StrCpy $R2 "" - StrCpy $R3 "" - StrCpy $R4 "" - StrCpy $R5 "" - StrCpy $R6 "" - - StrCmp $R0 `Upper Case` +5 - StrCmp $R0 `Lower Case` +4 - StrCmp $R0 `Title Case` +3 - StrCmp $R0 `Sentence Case` +2 - StrCpy $R0 `Sentence Case` - - loop: - StrCpy $R2 $R1 1 - StrCmp $R2 `` done - StrCpy $R1 $R1 `` 1 - - StrCmp $R0 `Upper Case` 0 +2 - StrCpy $R3 65 - - StrCmp $R0 `Lower Case` 0 +2 - StrCpy $R3 97 - - StrCmp $R0 `Title Case` 0 +6 - StrCmp $R6 ` ` +2 - StrCmp $R6 `` 0 +3 - StrCpy $R3 65 - Goto +2 - StrCpy $R3 97 - - StrCmp $R0 `Sentence Case` 0 +8 - StrCmp $R6 `.` +4 - StrCmp $R6 `!` +3 - StrCmp $R6 `?` +2 - StrCmp $R6 `` 0 +3 - StrCpy $R3 65 - Goto +2 - StrCpy $R3 97 - - loop2: - - IntFmt $R4 %c $R3 - - StrCmp $R2 $R4 0 +10 - StrCpy $R5 $R5$R4 - - StrCmp $R0 `Sentence Case` 0 loop - StrCmp $R2 ` ` 0 +5 - StrCmp $R6 `` +5 - StrCmp $R6 `.` +4 - StrCmp $R6 `!` +3 - StrCmp $R6 `?` +2 - - StrCpy $R6 $R2 - Goto loop - - IntOp $R3 $R3 + 1 - - StrCmp $R0 `Upper Case` 0 +3 - StrCpy $R4 91 - Goto +3 - StrCmp $R0 `Lower Case` 0 +2 - StrCpy $R4 123 - - StrCmp $R0 `Title Case` 0 +6 - StrCmp $R6 ` ` +2 - StrCmp $R6 `` 0 +3 - StrCpy $R4 91 - Goto +2 - StrCpy $R4 123 - - StrCmp $R0 `Sentence Case` 0 +8 - StrCmp $R6 `.` +4 - StrCmp $R6 `!` +3 - StrCmp $R6 `?` +2 - StrCmp $R6 `` 0 +3 - StrCpy $R4 97 - Goto +2 - StrCpy $R4 123 - - StrCmp $R0 `Sentence Case` +2 - StrCpy $R6 $R2 - - StrCmp $R3 $R4 0 Loop2 - StrCpy $R5 $R5$R2 - - StrCmp $R0 `Sentence Case` 0 +6 - StrCmp $R2 ` ` 0 +5 - StrCmp $R6 `` +5 - StrCmp $R6 `.` +4 - StrCmp $R6 `!` +3 - StrCmp $R6 `?` +2 - - StrCpy $R6 $R2 - - Goto loop - - done: - StrCpy $R0 $R5 - - Pop $R6 - Pop $R5 - Pop $R4 - Pop $R3 - Pop $R2 - Pop $R1 - Exch $R0 - FunctionEnd - -!macroend - -!macro FUNCTION_STRING_StrCase_Call ResultVar String Type - - !echo `$ {StrCase} "${ResultVar}" "${String}" "${Type}"$\r$\n` - - Push `${String}` - Push `${Type}` - - Call StrCase - - Pop `${ResultVar}` - -!macroend - -!macro FUNCTION_STRING_UnStrCase_Call ResultVar String Type - - !echo `$ {UnStrCase} "${ResultVar}" "${String}" "${Type}"$\r$\n` - - Push `${String}` - Push `${Type}` - - Call un.StrCase - - Pop `${ResultVar}` - -!macroend - -!macro FUNCTION_STRING_StrClbGet - - !echo `$\r$\n----------------------------------------------------------------------$\r$\nCopy From Clipboard Function - 2003-2004 Nik Medved - changed by Diego Pedroso$\r$\n----------------------------------------------------------------------$\r$\n$\r$\n` - - !ifdef FUNCTION_STRING_UninstSupport - !undef UnStrClbGet - !define UnStrClbGet `!insertmacro FUNCTION_STRING_UnStrClb_Get` - Function un.CopyFromClipboard - !else - !undef StrClbGet - !define StrClbGet `!insertmacro FUNCTION_STRING_StrClb_Get` - Function CopyFromClipboard - !endif - - Push $0 - System::Call 'user32::OpenClipboard(i 0)' - System::Call 'user32::GetClipboardData(i 1) t .r0' - System::Call 'user32::CloseClipboard()' - Exch $0 - FunctionEnd - -!macroend - -!macro FUNCTION_STRING_StrClb_Get ResultVar - - !echo `$ {StrClbGet} "${ResultVar}"$\r$\n` - - Call CopyFromClipboard - - Pop `${ResultVar}` - -!macroend - -!macro FUNCTION_STRING_UnStrClb_Get ResultVar - - !echo `$ {UnStrClbGet} "${ResultVar}"$\r$\n` - - Call un.CopyFromClipboard - - Pop `${ResultVar}` - -!macroend - -# Function StrClbSet -################## - -!macro FUNCTION_STRING_StrClbSet - - !echo `$\r$\n----------------------------------------------------------------------$\r$\nCopy To Clipboard - 2003-2004 Nik Medved$\r$\n----------------------------------------------------------------------$\r$\n$\r$\n` - - !ifdef FUNCTION_STRING_UninstSupport - !undef UnStrClbSet - !define UnStrClbSet `!insertmacro FUNCTION_STRING_UnStrClb_Set` - Function un.CopyToClipboard - !else - !undef StrClbSet - !define StrClbSet `!insertmacro FUNCTION_STRING_StrClb_Set` - Function CopyToClipboard - !endif - - Exch $0 ;input string - Push $1 - Push $2 - System::Call 'user32::OpenClipboard(i 0)' - System::Call 'user32::EmptyClipboard()' - StrLen $1 $0 - IntOp $1 $1 + 1 - System::Call 'kernel32::GlobalAlloc(i 2, i r1) i.r1' - System::Call 'kernel32::GlobalLock(i r1) i.r2' - System::Call 'kernel32::lstrcpyA(i r2, t r0)' - System::Call 'kernel32::GlobalUnlock(i r1)' - System::Call 'user32::SetClipboardData(i 1, i r1)' - System::Call 'user32::CloseClipboard()' - Pop $2 - Pop $1 - Pop $0 - FunctionEnd - -!macroend - -!macro FUNCTION_STRING_StrClb_Set String - - !echo `$ {StrClbSet} "${String}"$\r$\n` - - Push `${String}` - - Call CopyToClipboard - -!macroend - -!macro FUNCTION_STRING_UnStrClb_Set String - - !echo `$ {UnStrClbSet} "${String}"$\r$\n` - - Push `${String}` - - Call un.CopyToClipboard - -!macroend - -# Function StrIOToNSIS -#################### - -!macro FUNCTION_STRING_StrIOToNSIS - - !echo `$\r$\n----------------------------------------------------------------------$\r$\nInstall Options -> NSIS String Convertion Function - 2003-2004 Amir Szekely, Joost Verburg and Dave Laundon$\r$\n----------------------------------------------------------------------$\r$\n$\r$\n` - - !ifdef FUNCTION_STRING_UninstSupport + !insertmacro FUNCTION_STRING_StrCase + !macroend + + !insertmacro STRFUNC_DEFFUNC StrClb + !macro `FUNCTION_STRING_UnStrClb` + !undef UnStrClb + !insertmacro FUNCTION_STRING_StrClb + !macroend + + !insertmacro STRFUNC_DEFFUNC StrIOToNSIS + !macro `FUNCTION_STRING_UnStrIOToNSIS` !undef UnStrIOToNSIS - !define UnStrIOToNSIS `!insertmacro FUNCTION_STRING_UnStrIOToNSIS_Call` - Function un.Io2Nsis - !else - !undef StrIOToNSIS - !define StrIOToNSIS `!insertmacro FUNCTION_STRING_StrIOToNSIS_Call` - Function Io2Nsis - !endif + !insertmacro FUNCTION_STRING_StrIOToNSIS + !macroend - Exch $0 ; The source - Push $1 ; The output - Push $2 ; Temporary char - StrCpy $1 `` ; Initialise the output - loop: - StrCpy $2 $0 1 ; Get the next source char - StrCmp $2 `` done ; Abort when none left - StrCpy $0 $0 `` 1 ; Remove it from the source - StrCmp $2 `\` +3 ; Escape character? - StrCpy $1 `$1$2` ; If not just output - Goto loop - StrCpy $2 $0 1 ; Get the next source char - StrCpy $0 $0 `` 1 ; Remove it from the source - StrCmp $2 `\` `` +3 ; Back-slash? - StrCpy $1 `$1\` - Goto loop - StrCmp $2 `r` `` +3 ; Carriage return? - StrCpy $1 `$1$\r` - Goto loop - StrCmp $2 `n` `` +3 ; Line feed? - StrCpy $1 `$1$\n` - Goto loop - StrCmp $2 `t` `` +3 ; Tab? - StrCpy $1 `$1$\t` - Goto loop - StrCpy $1 `$1$2` ; Anything else (should never get here) - Goto loop - done: - StrCpy $0 $1 - Pop $2 - Pop $1 - Exch $0 - FunctionEnd - -!macroend - -!macro FUNCTION_STRING_StrIOToNSIS_Call ResultVar String - - !echo `$ {StrIOToNSIS} "${ResultVar}" "${String}"$\r$\n` - - Push `${String}` - - Call IO2NSIS - - Pop `${ResultVar}` - -!macroend - -!macro FUNCTION_STRING_UnStrIOToNSIS_Call ResultVar String - - !echo `$ {UnStrIOToNSIS} "${ResultVar}" "${String}"$\r$\n` - - Push `${String}` - - Call un.IO2NSIS - - Pop `${ResultVar}` - -!macroend - -# Function StrLoc -############### - -!macro FUNCTION_STRING_StrLoc - - !echo `$\r$\n----------------------------------------------------------------------$\r$\nLocalize in String Function - © 2004 Diego Pedroso\r$\n----------------------------------------------------------------------$\r$\n$\r$\n` - - !ifdef FUNCTION_STRING_UninstSupport + !insertmacro STRFUNC_DEFFUNC StrLoc + !macro `FUNCTION_STRING_UnStrLoc` !undef UnStrLoc - !define UnStrLoc `!insertmacro FUNCTION_STRING_UnStrLoc_Call` - Function un.StrLoc - !else - !undef StrLoc - !define StrLoc `!insertmacro FUNCTION_STRING_StrLoc_Call` - Function StrLoc - !endif + !insertmacro FUNCTION_STRING_StrLoc + !macroend - Exch $R0 - Exch - Exch $R1 ; st=haystack,old$R1, $R1=needle - Exch 2 ; st=old$R1,haystack - Exch $R2 ; st=old$R1,old$R2, $R2=haystack - Push $R3 - Push $R4 - Push $R5 - StrLen $R3 $R1 - StrCpy $R4 0 - loop: - StrCpy $R5 $R2 $R3 $R4 - StrCmp $R5 $R1 done - StrCmp $R5 `` error - IntOp $R4 $R4 + 1 - Goto loop - done: - - StrCmp $R0 `<` 0 +5 - StrLen $R0 $R2 - IntOp $R5 $R3 + $R4 - IntOp $R0 $R0 - $R5 - Goto +2 - - StrCpy $R0 $R4 - Goto +2 - - error: - StrCpy $R0 `` - - Pop $R5 - Pop $R4 - Pop $R3 - Pop $R2 - Exch - Pop $R1 - Exch $R0 - FunctionEnd - -!macroend - -!macro FUNCTION_STRING_StrLoc_Call ResultVar String StrToSearchFor OffsetDirection - - !echo `$ {StrLoc} "${ResultVar}" "${String}" "${StrToSearchFor}" "${OffsetDirection}"$\r$\n` - - Push `${String}` - Push `${StrToSearchFor}` - Push `${OffsetDirection}` - - Call StrLoc - - Pop `${ResultVar}` - -!macroend - -!macro FUNCTION_STRING_UnStrLoc_Call ResultVar String StrToSearchFor OffsetDirection - - !echo `$ {UnStrLoc} "${ResultVar}" "${String}" "${StrToSearchFor}" "${OffsetDirection}"$\r$\n` - - Push `${String}` - Push `${StrToSearchFor}` - Push `${OffsetDirection}` - - Call un.StrLoc - - Pop `${ResultVar}` - -!macroend - -# Function StrNSISToIO -#################### - -!macro FUNCTION_STRING_StrNSISToIO - - !echo `$\r$\n----------------------------------------------------------------------$\r$\nNSIS -> Install Options String Convertion Function - 2003-2004 Amir Szekely, Joost Verburg and Dave Laundon$\r$\n----------------------------------------------------------------------$\r$\n$\r$\n` - - !ifdef FUNCTION_STRING_UninstSupport + !insertmacro STRFUNC_DEFFUNC StrNSISToIO + !macro `FUNCTION_STRING_UnStrNSISToIO` !undef UnStrNSISToIO - !define UnStrNSISToIO `!insertmacro FUNCTION_STRING_UnStrNSISToIO_Call` - Function un.Nsis2Io - !else - !undef StrNSISToIO - !define StrNSISToIO `!insertmacro FUNCTION_STRING_StrNSISToIO_Call` - Function Nsis2Io - !endif + !insertmacro FUNCTION_STRING_StrNSISToIO + !macroend - Exch $0 ; The source - Push $1 ; The output - Push $2 ; Temporary char - StrCpy $1 `` ; Initialise the output - loop: - StrCpy $2 $0 1 ; Get the next source char - StrCmp $2 `` done ; Abort when none left - StrCpy $0 $0 `` 1 ; Remove it from the source - StrCmp $2 `\` `` +3 ; Back-slash? - StrCpy $1 `$1\\` - Goto loop - StrCmp $2 `$\r` `` +3 ; Carriage return? - StrCpy $1 `$1\r` - Goto loop - StrCmp $2 `$\n` `` +3 ; Line feed? - StrCpy $1 `$1\n` - Goto loop - StrCmp $2 `$\t` `` +3 ; Tab? - StrCpy $1 `$1\t` - Goto loop - StrCpy $1 `$1$2` ; Anything else - Goto loop - done: - StrCpy $0 $1 - Pop $2 - Pop $1 - Exch $0 - FunctionEnd - -!macroend - -!macro FUNCTION_STRING_StrNSISToIO_Call ResultVar String - - !echo `$ {StrNSISToIO} "${ResultVar}" "${String}"$\r$\n` - - Push `${String}` - - Call NSIS2IO - - Pop `${ResultVar}` - -!macroend - -!macro FUNCTION_STRING_UnStrNSISToIO_Call ResultVar String - - !echo `$ {UnStrNSISToIO} "${ResultVar}" "${String}"$\r$\n` - - Push `${String}` - - Call un.NSIS2IO - - Pop `${ResultVar}` - -!macroend - -# Function StrRep -############### - -!macro FUNCTION_STRING_StrRep - - !echo `$\r$\n----------------------------------------------------------------------$\r$\nReplace String Function - 2002-2004 Hendri Adriaens$\r$\n----------------------------------------------------------------------$\r$\n$\r$\n` - - !ifdef FUNCTION_STRING_UninstSupport + !insertmacro STRFUNC_DEFFUNC StrRep + !macro `FUNCTION_STRING_UnStrRep` !undef UnStrRep - !define UnStrRep `!insertmacro FUNCTION_STRING_UnStrRep_Call` - Function un.StrReplace - !else - !undef StrRep - !define StrRep `!insertmacro FUNCTION_STRING_StrRep_Call` - Function StrReplace - !endif + !insertmacro FUNCTION_STRING_StrRep + !macroend - Exch $0 ;this will replace wrong characters - Exch - Exch $1 ;needs to be replaced - Exch - Exch 2 - Exch $2 ;the orginal string - Push $3 ;counter - Push $4 ;temp character - Push $5 ;temp string - Push $6 ;length of string that need to be replaced - Push $7 ;length of string that will replace - Push $R0 ;tempstring - Push $R1 ;tempstring - Push $R2 ;tempstring - StrCpy $3 `-1` - StrCpy $5 `` - StrLen $6 $1 - StrLen $7 $0 - Loop: - IntOp $3 $3 + 1 - StrCpy $4 $2 $6 $3 - StrCmp $4 `` ExitLoop - StrCmp $4 $1 Replace - Goto Loop - Replace: - StrCpy $R0 $2 $3 - IntOp $R2 $3 + $6 - StrCpy $R1 $2 `` $R2 - StrCpy $2 $R0$0$R1 - IntOp $3 $3 + $7 - Goto Loop - ExitLoop: - StrCpy $0 $2 - Pop $R2 - Pop $R1 - Pop $R0 - Pop $7 - Pop $6 - Pop $5 - Pop $4 - Pop $3 - Pop $2 - Pop $1 - Exch $0 - FunctionEnd - -!macroend - -!macro FUNCTION_STRING_StrRep_Call ResultVar String StringToReplace ReplacementString - - !echo `$ {StrRep} "${ResultVar}" "${String}" "${StringToReplace}" "${ReplacementString}"$\r$\n` - - Push `${String}` - Push `${StringToReplace}` - Push `${ReplacementString}` - - Call StrReplace - - Pop `${ResultVar}` - -!macroend - -!macro FUNCTION_STRING_UnStrRep_Call ResultVar String StringToReplace ReplacementString - - !echo `$ {UnStrRep} "${ResultVar}" "${String}" "${StringToReplace}" "${ReplacementString}"$\r$\n` - - Push `${String}` - Push `${StringToReplace}` - Push `${ReplacementString}` - - Call un.StrReplace - - Pop `${ResultVar}` - -!macroend - -# Function StrSort -################ - -!macro FUNCTION_STRING_StrSort - - !echo `$\r$\n----------------------------------------------------------------------$\r$\nAdvanced String Sort Function - © 2004 Diego Pedroso$\r$\n----------------------------------------------------------------------$\r$\n$\r$\n` - - !ifdef FUNCTION_STRING_UninstSupport + !insertmacro STRFUNC_DEFFUNC StrSort + !macro `FUNCTION_STRING_UnStrSort` !undef UnStrSort - !define UnStrSort `!insertmacro FUNCTION_STRING_UnStrSort_Call` - Function un.AdvStrSort - !else - !undef StrSort - !define StrSort `!insertmacro FUNCTION_STRING_StrSort_Call` - Function AdvStrSort - !endif + !insertmacro FUNCTION_STRING_StrSort + !macroend - # Prepare Variables + !insertmacro STRFUNC_DEFFUNC StrStr + !macro `FUNCTION_STRING_UnStrStr` + !undef UnStrStr + !insertmacro FUNCTION_STRING_StrStr + !macroend - Exch $R7 ;Include Center string - Exch - Exch $R6 ;Include Left and Right strings - Exch 2 - Exch $0 ;Right String - Exch 3 - Exch $1 ;Left String - Exch 4 - Exch $2 ;Center String - Exch 5 - Exch $R0 ;String - Push $3 - Push $4 - Push $5 - Push $R1 - Push $R2 - Push $R3 - Push $R4 - Push $R5 + !insertmacro STRFUNC_DEFFUNC StrStrAdv + !macro `FUNCTION_STRING_UnStrStrAdv` + !undef UnStrStrAdv + !insertmacro FUNCTION_STRING_StrStrAdv + !macroend - StrLen $3 $0 - StrLen $4 $1 - StrLen $5 $2 - StrCpy $R1 0 + !insertmacro STRFUNC_DEFFUNC StrTok + !macro `FUNCTION_STRING_UnStrTok` + !undef UnStrTok + !insertmacro FUNCTION_STRING_StrTok + !macroend - # Center String Search + !insertmacro STRFUNC_DEFFUNC StrTrimNewLines + !macro `FUNCTION_STRING_UnStrTrimNewLines` + !undef UnStrTrimNewLines + !insertmacro FUNCTION_STRING_StrTrimNewLines + !macroend + ;Function Codes for Install and Uninstall + + # Function StrCase + ################ + + !macro FUNCTION_STRING_StrCase + !insertmacro STRFUNC_FUNC `StrCase` `2004 Diego Pedroso - Based on StrUpper and StrLower by Dave Laundon` + + Exch $1 + Exch + Exch $0 + Push $2 + Push $3 + Push $4 + Push $5 + Push $6 + Push $7 + Push $8 + + ; Clean pushed variables + + StrCpy $2 "" + StrCpy $3 "" + StrCpy $4 "" + StrCpy $5 "" + StrCpy $6 "" + StrCpy $7 "" + StrCpy $8 "" + + ${If} $1 == "U" + + ;Upper Case System: + ;------------------ + ; Convert all characters to upper case. + + System::Call "User32::CharUpper(t r0 r5)i" + Goto StrCase_End + ${ElseIf} $1 == "L" + + ;Lower Case System: + ;------------------ + ; Convert all characters to lower case. + + System::Call "User32::CharLower(t r0 r5)i" + Goto StrCase_End + ${EndIf} + + StrLen $2 $0 + + ; For the rest of cases, make a loop + ${For} $3 0 $2 + + IntOp $4 $3 + 1 + + ; Step 1: Detect one character at a time + + ${If} $3 <> 0 + StrCpy $6 $0 `` $3 + ${EndIf} + + ${If} $4 <> $2 + ${If} $3 = 0 + StrCpy $6 $0 1 + ${Else} + StrCpy $6 $6 1 + ${EndIf} + ${EndIf} + + ; Step 2: Convert to the advanced case user chose: + + ${If} $1 == "T" + + ;Title Case System: + ;------------------ + ; Convert all characters after a non-alphabetic character to upper case. + ; Else convert to lower case. + + System::Call "*(&t1 r7) i .r8" + System::Call "*$8(&i1 .r7)" + System::Free $8 + System::Call "user32::IsCharAlpha(i r7) i .r8" + ${If} $8 = 0 + System::Call "User32::CharUpper(t r6 r6)i" + ${Else} + System::Call "User32::CharLower(t r6 r6)i" + ${EndIf} + ${ElseIf} $1 == "S" + + ;Sentence Case System: + ;------------------ + ; Convert all characters after a ".", "!" or "?" character to upper case. + ; Else convert to lower case. Spaces or tabs after these marks are ignored. + + ${If} $6 == " " + ${OrIf} $6 == "$\t" + Goto IgnoreLetter + ${EndIf} + + ${If} $7 == "." + ${OrIf} $7 == "!" + ${OrIf} $7 == "?" + ${OrIf} $7 == "" + System::Call "User32::CharUpper(t r6 r6)i" + ${Else} + System::Call "User32::CharLower(t r6 r6)i" + ${EndIf} + ${ElseIf} $1 == "<>" + + ;Switch Case System: + ;------------------ + ; Switch all characters cases to their inverse case. + + System::Call "*(&t1 r6) i .r8" + System::Call "*$8(&i1 .r7)" + System::Free $8 + System::Call "user32::IsCharUpper(i r7) i .r8" + ${If} $8 = 0 + System::Call "User32::CharUpper(t r6 r6)i" + ${Else} + System::Call "User32::CharLower(t r6 r6)i" + ${EndIf} + ${EndIf} + + ; Write the character to TempString + + StrCpy $7 $6 + + IgnoreLetter: + StrCpy $5 `$5$6` + + ${Next} + + StrCase_End: + + ; TempString is the final string + + StrCpy $0 $5 + + Pop $8 + Pop $7 + Pop $6 + Pop $5 + Pop $4 + Pop $3 + Pop $2 + Pop $1 + Exch $0 + + FunctionEnd + + !macroend + + !macro FUNCTION_STRING_StrClb + !insertmacro STRFUNC_FUNC `StrClb` `2004 Diego Pedroso - Based on CopyToClipboard and CopyFromClipboard by Nik Medved` + + ;Get input from user + + Exch $1 + Exch + Exch $0 + Exch + Push $2 + Push $3 + Push $4 + + ;Open the clipboard to do the operations the user chose + System::Call 'user32::OpenClipboard(i $HWNDPARENT)' + + ${If} $1 == ">" ;Set + + ;Step 1: Clear the clipboard + System::Call 'user32::EmptyClipboard()' + + ;Step 2: Allocate global heap + StrLen $2 $0 + IntOp $2 $2 + 1 + System::Call 'kernel32::GlobalAlloc(i 2, i r2) i.r2' + + ;Step 3: Lock the handle + System::Call 'kernel32::GlobalLock(i r2) i.r3' + + ;Step 4: Copy the text to locked clipboard buffer + System::Call 'kernel32::lstrcpyA(i r3, t r0)' + + ;Step 5: Unlock the handle again + System::Call 'kernel32::GlobalUnlock(i r2)' + + ;Step 6: Set the information to the clipboard + System::Call 'user32::SetClipboardData(i 1, i r2)' + + StrCpy $0 "" + + ${ElseIf} $1 == "<" ;Get + + ;Step 1: Get clipboard data + System::Call 'user32::GetClipboardData(i 1) i .r2' + + ;Step 2: Lock and copy data + System::Call 'kernel32::GlobalLock(i r2) t .r0' + + ;Step 3: Unlcok + System::Call 'kernel32::GlobalUnlock(i r2)' + + ${ElseIf} $1 == "<>" ;Swap + + ;Step 1: Get clipboard data + System::Call 'user32::GetClipboardData(i 1) t .r2' + + ;Step 2: Lock and copy data + System::Call 'kernel32::GlobalLock(i r2) t .r4' + + ;Step 3: Unlcok + System::Call 'kernel32::GlobalUnlock(i r2)' + + ;Step 4: Clear the clipboard + System::Call 'user32::EmptyClipboard()' + + ;Step 5: Allocate global heap + StrLen $2 $0 + IntOp $2 $2 + 1 + System::Call 'kernel32::GlobalAlloc(i 2, i r2) i.r2' + + ;Step 6: Lock the handle + System::Call 'kernel32::GlobalLock(i r2) i.r3' + + ;Step 7: Copy the text to locked clipboard buffer + System::Call 'kernel32::lstrcpyA(i r3, t r0)' + + ;Step 8: Unlock the handle again + System::Call 'kernel32::GlobalUnlock(i r2)' + + ;Step 9: Set the information to the clipboard + System::Call 'user32::SetClipboardData(i 1, i r2)' + + StrCpy $0 $4 + ${Else} ;Clear + + ;Step 1: Clear the clipboard + System::Call 'user32::EmptyClipboard()' + + StrCpy $0 "" + ${EndIf} + + ;Close the clipboard + System::Call 'user32::CloseClipboard()' + + ;Return result to user + + Pop $4 + Pop $3 + Pop $2 + Pop $1 + Exch $0 + + FunctionEnd + + !macroend + + # Function StrIOToNSIS + #################### + + !macro FUNCTION_STRING_StrIOToNSIS + !insertmacro STRFUNC_FUNC `StrIOToNSIS` `2003-2004 Amir Szekely, Joost Verburg and Dave Laundon` + + Exch $0 ; The source + Push $1 ; The output + Push $2 ; Temporary char + StrCpy $1 `` ; Initialise the output loop: - StrCpy $R3 $R0 $5 $R1 - StrCmp $R3 `` error - StrCmp $R3 $2 done - IntOp $R1 $R1 + 1 + StrCpy $2 $0 1 ; Get the next source char + StrCmp $2 `` done ; Abort when none left + StrCpy $0 $0 `` 1 ; Remove it from the source + StrCmp $2 `\` +3 ; Escape character? + StrCpy $1 `$1$2` ; If not just output Goto loop + StrCpy $2 $0 1 ; Get the next source char + StrCpy $0 $0 `` 1 ; Remove it from the source + StrCmp $2 `\` `` +3 ; Back-slash? + StrCpy $1 `$1\` + Goto loop + StrCmp $2 `r` `` +3 ; Carriage return? + StrCpy $1 `$1$\r` + Goto loop + StrCmp $2 `n` `` +3 ; Line feed? + StrCpy $1 `$1$\n` + Goto loop + StrCmp $2 `t` `` +3 ; Tab? + StrCpy $1 `$1$\t` + Goto loop + StrCpy $1 `$1$2` ; Anything else (should never get here) + Goto loop done: + StrCpy $0 $1 + Pop $2 + Pop $1 + Exch $0 + FunctionEnd - StrCpy $R5 $R1 + !macroend - IntOp $R1 $R1 - $4 + # Function StrLoc + ############### - # Left String Search + !macro FUNCTION_STRING_StrLoc + !insertmacro STRFUNC_FUNC `StrLoc` `2004 Diego Pedroso` - loop2: - StrCpy $R3 $R0 $4 $R1 - StrCmp $R3 `` error2 - StrCmp $R3 $1 done2 - IntOp $R1 $R1 - 1 - Goto loop2 + Exch $R0 + Exch + Exch $R1 ; st=haystack,old$R1, $R1=needle + Exch 2 ; st=old$R1,haystack + Exch $R2 ; st=old$R1,old$R2, $R2=haystack + Push $R3 + Push $R4 + Push $R5 + StrLen $R3 $R1 + StrCpy $R4 0 + loop: + StrCpy $R5 $R2 $R3 $R4 + StrCmp $R5 $R1 done + StrCmp $R5 `` error + IntOp $R4 $R4 + 1 + Goto loop + done: - error2: - StrCpy $R1 0 - StrCpy $R3 0 + StrCmp $R0 `<` 0 +5 + StrLen $R0 $R2 + IntOp $R5 $R3 + $R4 + IntOp $R0 $R0 - $R5 + Goto +2 + + StrCpy $R0 $R4 Goto +2 - done2: - StrCpy $R3 1 + error: + StrCpy $R0 `` - StrCpy $R4 $R0 $R5 + Pop $R5 + Pop $R4 + Pop $R3 + Pop $R2 + Exch + Pop $R1 + Exch $R0 + FunctionEnd - StrCmp $R1 0 +2 - StrCpy $R4 $R4 `` $R1 + !macroend - StrCmp $R3 1 0 +3 - StrCmp $R6 0 0 +2 - StrCpy $R4 $R4 `` $4 + # Function StrNSISToIO + #################### - # Center String Addition + !macro FUNCTION_STRING_StrNSISToIO + !insertmacro STRFUNC_FUNC `StrNSISToIO` `2003-2004 Amir Szekely, Joost Verburg and Dave Laundon` - StrCmp $R7 0 +2 - StrCpy $R4 $R4$2 + Exch $0 ; The source + Push $1 ; The output + Push $2 ; Temporary char + StrCpy $1 `` ; Initialise the output + loop: + StrCpy $2 $0 1 ; Get the next source char + StrCmp $2 `` done ; Abort when none left + StrCpy $0 $0 `` 1 ; Remove it from the source + StrCmp $2 `\` `` +3 ; Back-slash? + StrCpy $1 `$1\\` + Goto loop + StrCmp $2 `$\r` `` +3 ; Carriage return? + StrCpy $1 `$1\r` + Goto loop + StrCmp $2 `$\n` `` +3 ; Line feed? + StrCpy $1 `$1\n` + Goto loop + StrCmp $2 `$\t` `` +3 ; Tab? + StrCpy $1 `$1\t` + Goto loop + StrCpy $1 `$1$2` ; Anything else + Goto loop + done: + StrCpy $0 $1 + Pop $2 + Pop $1 + Exch $0 + FunctionEnd - StrCpy $R1 $R5 - IntOp $R1 $R1 + $5 + !macroend - # Right String Search + # Function StrRep + ############### - loop3: + !macro FUNCTION_STRING_StrRep + !insertmacro STRFUNC_FUNC `StrRep` `2002-2004 Hendri Adriaens` - StrCpy $R3 $R0 $3 $R1 - StrCmp $R3 `` error3 - StrCmp $R3 $0 done3 - IntOp $R1 $R1 + 1 - Goto loop3 + Exch $0 ;this will replace wrong characters + Exch + Exch $1 ;needs to be replaced + Exch + Exch 2 + Exch $2 ;the orginal string + Push $3 ;counter + Push $4 ;temp character + Push $5 ;temp string + Push $6 ;length of string that need to be replaced + Push $7 ;length of string that will replace + Push $R0 ;tempstring + Push $R1 ;tempstring + Push $R2 ;tempstring + StrCpy $3 `-1` + StrCpy $5 `` + StrLen $6 $1 + StrLen $7 $0 + Loop: + IntOp $3 $3 + 1 + StrCpy $4 $2 $6 $3 + StrCmp $4 `` ExitLoop + StrCmp $4 $1 Replace + Goto Loop + Replace: + StrCpy $R0 $2 $3 + IntOp $R2 $3 + $6 + StrCpy $R1 $2 `` $R2 + StrCpy $2 $R0$0$R1 + IntOp $3 $3 + $7 + Goto Loop + ExitLoop: + StrCpy $0 $2 + Pop $R2 + Pop $R1 + Pop $R0 + Pop $7 + Pop $6 + Pop $5 + Pop $4 + Pop $3 + Pop $2 + Pop $1 + Exch $0 + FunctionEnd - error3: + !macroend + + # Function StrSort + ################ + + !macro FUNCTION_STRING_StrSort + !insertmacro STRFUNC_FUNC `StrSort` `2004 Diego Pedroso - based on SortString by "Afrow UK"` + + # Prepare Variables + + Exch $R7 ;Include Center string + Exch + Exch $R6 ;Include Left and Right strings + Exch 2 + Exch $0 ;Right String + Exch 3 + Exch $1 ;Left String + Exch 4 + Exch $2 ;Center String + Exch 5 + Exch $R0 ;String + Push $3 + Push $4 + Push $5 + Push $R1 + Push $R2 + Push $R3 + Push $R4 + Push $R5 + + StrLen $3 $0 + StrLen $4 $1 + StrLen $5 $2 StrCpy $R1 0 - done3: + # Center String Search - IntOp $R5 $R5 + $5 - StrCpy $R3 $R0 `` $R5 + loop: + StrCpy $R3 $R0 $5 $R1 + StrCmp $R3 `` error + StrCmp $R3 $2 done + IntOp $R1 $R1 + 1 + Goto loop + done: - StrCmp $R1 0 +5 - IntOp $R1 $R1 - $R5 - StrCmp $R6 0 +2 - IntOp $R1 $R1 + $3 - StrCpy $R3 $R3 $R1 + StrCpy $R5 $R1 - StrCpy $R4 $R4$R3 + IntOp $R1 $R1 - $4 - StrCpy $2 $R4 - Goto +2 + # Left String Search - Error: - StrCpy $2 `` - - # Return to User - - Pop $R5 - Pop $R4 - Pop $R3 - Pop $R2 - Pop $R1 - Pop $5 - Pop $4 - Pop $3 - Pop $R0 - Pop $R7 - Pop $R6 - Pop $0 - Pop $1 - Exch $2 - - FunctionEnd - -!macroend - -!macro FUNCTION_STRING_StrSort_Call ResultVar String CenterStr LeftStr RightStr IncludeLeftRightStr IncludeCenterStr - - !echo `$ {StrSort} "${ResultVar}" "${String}" "${CenterStr}" "${LeftStr}" "${RightStr}" "${IncludeLeftRightStr}" "${IncludeCenterStr}"$\r$\n` - - Push `${String}` - Push `${CenterStr}` - Push `${LeftStr}` - Push `${RightStr}` - Push `${IncludeLeftRightStr}` - Push `${IncludeCenterStr}` - - Call AdvStrSort - - Pop `${ResultVar}` - -!macroend - -!macro FUNCTION_STRING_UnStrSort_Call ResultVar String CenterStr LeftStr RightStr IncludeLeftRightStr IncludeCenterStr - - !echo `$ {UnStrSort} "${ResultVar}" "${String}" "${CenterStr}" "${LeftStr}" "${RightStr}" "${IncludeLeftRightStr}" "${IncludeCenterStr}"$\r$\n` - - Push `${String}` - Push `${CenterStr}` - Push `${LeftStr}` - Push `${RightStr}` - Push `${IncludeLeftRightStr}` - Push `${IncludeCenterStr}` - - Call un.AdvStrSort - - Pop `${ResultVar}` - -!macroend - -# Function StrStr -############### - -!macro FUNCTION_STRING_StrStr - - !echo `$\r$\n----------------------------------------------------------------------$\r$\nSearch in String Function - 2002-2004 Ximon Eighteen\r$\n----------------------------------------------------------------------$\r$\n$\r$\n` - - !ifdef FUNCTION_STRING_UninstSupport - !undef UnStrStr - !define UnStrStr `!insertmacro FUNCTION_STRING_UnStrStr_Call` - Function un.StrStr - !else - !undef StrStr - !define StrStr `!insertmacro FUNCTION_STRING_StrStr_Call` - Function StrStr - !endif - - Exch $R1 ; st=haystack,old$R1, $R1=needle - Exch ; st=old$R1,haystack - Exch $R2 ; st=old$R1,old$R2, $R2=haystack - Push $R3 - Push $R4 - Push $R5 - StrLen $R3 $R1 - StrCpy $R4 0 - ; $R1=needle - ; $R2=haystack - ; $R3=len(needle) - ; $R4=cnt - ; $R5=tmp - loop: - StrCpy $R5 $R2 $R3 $R4 - StrCmp $R5 $R1 done - StrCmp $R5 `` done - IntOp $R4 $R4 + 1 - Goto loop - done: - StrCpy $R1 $R2 `` $R4 - Pop $R5 - Pop $R4 - Pop $R3 - Pop $R2 - Exch $R1 - FunctionEnd - -!macroend - -!macro FUNCTION_STRING_StrStr_Call ResultVar String StrToSearchFor - - !echo `$ {StrStr} "${ResultVar}" "${String}" "${StrToSearchFor}"$\r$\n` - - Push `${String}` - Push `${StrToSearchFor}` - - Call StrStr - - Pop `${ResultVar}` - -!macroend - -!macro FUNCTION_STRING_UnStrStr_Call ResultVar String StrToSearchFor - - !echo `$ {UnStrStr} "${ResultVar}" "${String}" "${StrToSearchFor}"$\r$\n` - - Push `${String}` - Push `${StrToSearchFor}` - - Call un.StrStr - - Pop `${ResultVar}` - -!macroend - -# Function StrStrAdv -################## - -!macro FUNCTION_STRING_StrStrAdv - - !echo `$\r$\n----------------------------------------------------------------------$\r$\nAdvanced Search in String Function - © 2003-2004 Diego Pedroso$\r$\n----------------------------------------------------------------------$\r$\n$\r$\n` - - !ifdef FUNCTION_STRING_UninstSupport - !undef UnStrStrAdv - !define UnStrStrAdv `!insertmacro FUNCTION_STRING_UnStrStrAdv_Call` - Function un.AdvancedStrStr - !else - !undef StrStrAdv - !define StrStrAdv `!insertmacro FUNCTION_STRING_StrStrAdv_Call` - Function AdvancedStrStr - !endif - - # Preparing Variables - - Exch $R9 - Exch - Exch $R8 - Exch - Exch 2 - Exch $R7 - Exch 2 - Exch 3 - Exch $R6 - Exch 3 - Exch 4 - Exch $R5 - Exch 4 - Exch 5 - Exch $R4 - Exch 5 - Push $R3 - Push $R2 - Push $R1 - Push $R0 - Push $9 - Push $8 - Push $7 - Push $6 - StrCpy $R2 $R4 - StrCpy $R1 $R5 - StrCpy $R4 `` - StrCpy $R5 `` - StrCpy $7 $R2 - - StrCpy $6 "" - - # Detect Empty Input - - StrCmp $R1 `` 0 +3 - SetErrors - Goto granddone - - StrCmp $R2 `` 0 +3 - SetErrors - Goto granddone - - StrCmp $R6 `` 0 +2 - StrCpy $R6 > - - StrCmp $R7 `` 0 +2 - StrCpy $R7 > - - # Preparing StrStr - - StrCpy $R0 0 - - IntCmp $R9 1 +2 0 +2 - StrCpy $R9 0 - - IntOp $R9 $R9 + 1 - - # Loops and more loops if you want... - - grandloop: - - # Detect if the loops number given by user = code runs... - - StrCpy $R4 0 - StrLen $R3 $R1 - StrCpy $6 $R3 - StrCmp $9 1 0 +4 - StrCmp $R6 `<` 0 +2 - IntOp $R3 $R3 + 1 - IntOp $R4 $R4 + 1 - - StrCmp $R6 `<` 0 +5 - IntOp $R3 $R3 * -1 - StrCpy $6 $R3 - IntCmp $R0 0 +2 0 0 - IntOp $6 $6 + 1 - - # Searching the string - - loop: - - # RTL... - - StrCmp $R6 `<` 0 EndBack - - IntOp $9 $R4 * -1 - - StrCmp $9 0 0 +3 - StrCpy $R5 $R2 `` $R3 - Goto +2 - StrCpy $R5 $R2 $9 $R3 - Goto +2 - - EndBack: - - # LTR... - - StrCpy $R5 $R2 $R3 $R4 - - # Detect if the value returned is the searched... - - StrCmp $R5 $R1 done - - StrCmp $R5 `` granddone - - # If not, make a loop... - - IntOp $R4 $R4 + 1 - StrCmp $R6 `<` 0 +2 - IntOp $R3 $R3 - 1 - - Goto loop - - done: - - StrCmp $R6 `<` 0 +3 - IntOp $8 $9 + $8 - Goto +2 - IntOp $8 $R4 + $8 - - # Looping Calculation... - - IntOp $R0 $R0 + 1 - - IntCmp $R0 $R9 0 continueloop 0 - - # Customizing the string to fit user conditions (supported by loops)... - - # RTL... - - StrCmp $R6 `<` 0 EndBackward - StrCmp $R7 `>` 0 +7 - StrCmp $8 0 0 +3 - StrCpy $R2 `` - Goto +2 - StrCpy $R2 $7 `` $8 - StrCpy $R2 $R1$R2 - Goto +3 - - StrCmp $9 0 +2 - StrCpy $R2 $R2 $9 - - StrCmp $R8 1 EndForward 0 - StrCmp $R7 `>` 0 End> - Push $6 - IntOp $6 $6 * -1 - StrCpy $R2 $R2 `` $6 - Pop $6 - Goto +2 - End>: - StrCpy $R2 $R2 $6 - Goto EndForward - EndBackward: - - # LTR... - - StrCmp $R7 `<` 0 +4 - StrCpy $R2 $7 $8 - StrCpy $R2 $R2$R1 - Goto +2 - StrCpy $R2 $R2 `` $R4 - StrCmp $R8 1 EndForward 0 - StrCmp $R7 `<` 0 End< - Push $6 - IntOp $6 $6 * -1 - StrCpy $R2 $R2 $6 - Pop $6 - Goto +2 - End<: - StrCpy $R2 $R2 `` $R3 - EndForward: - - Goto stoploop - - continueloop: - - # Customizing the string to fits user conditions (not supported by loops)... - - # RTL... - - StrCmp $R6 `<` 0 +4 - StrCmp $9 0 +4 - StrCpy $R2 $R2 $9 - Goto +2 - - # LTR... - - StrCpy $R2 $R2 `` $R4 - - stoploop: - - # Return to grandloop init... - - StrCpy $9 1 - - IntCmp $R0 $R9 0 grandloop 0 - - StrCpy $R4 $R2 - - Goto +2 - - granddone: - - # Return the result to user - - StrCpy $R4 `` - - Pop $6 - Pop $7 - Pop $8 - Pop $9 - Pop $R0 - Pop $R1 - Pop $R2 - Pop $R3 - Pop $R9 - Pop $R8 - Pop $R7 - Pop $R6 - Pop $R5 - Exch $R4 - - FunctionEnd - -!macroend - -!macro FUNCTION_STRING_StrStrAdv_Call ResultVar String StrToSearchFor SearchDirection ResultStrDirection DisplayStrToSearch Loops - - !echo `$ {StrStrAdv} "${ResultVar}" "${String}" "${StrToSearchFor}" "${SearchDirection}" "${ResultStrDirection}" "${DisplayStrToSearch}" "${Loops}"$\r$\n` - - Push `${String}` - Push `${StrToSearchFor}` - Push `${SearchDirection}` - Push `${ResultStrDirection}` - Push `${DisplayStrToSearch}` - Push `${Loops}` - - Call AdvancedStrStr - - Pop `${ResultVar}` - -!macroend - -!macro FUNCTION_STRING_UnStrStrAdv_Call ResultVar String StrToSearchFor SearchDirection ResultStrDirection DisplayStrToSearch Loops - - !echo `$ {UnStrStrAdv} "${ResultVar}" "${String}" "${StrToSearchFor}" "${SearchDirection}" "${ResultStrDirection}" "${DisplayStrToSearch}" "${Loops}"$\r$\n` - - Push `${String}` - Push `${StrToSearchFor}` - Push `${SearchDirection}` - Push `${ResultStrDirection}` - Push `${DisplayStrToSearch}` - Push `${Loops}` - - Call un.AdvancedStrStr - - Pop `${ResultVar}` - -!macroend - -# Function StrTok -############### - -!macro FUNCTION_STRING_StrTok - - !echo `$\r$\n----------------------------------------------------------------------$\r$\nAdvanced Token String Function - © 2004 Diego Pedroso$\r$\n----------------------------------------------------------------------$\r$\n$\r$\n` - - !ifdef FUNCTION_STRING_UninstSupport - !undef UnStrTok - !define UnStrTok `!insertmacro FUNCTION_STRING_UnStrTok_Call` - Function un.AdvancedStrTok - !else - !undef StrTok - !define StrTok `!insertmacro FUNCTION_STRING_StrTok_Call` - Function AdvancedStrTok - !endif - - Exch $9 - Exch - Exch $R0 - Exch 2 - Exch $R1 - Exch 3 - Exch $R2 - Push $R3 - Push $R4 - Push $R5 - Push $R6 - Push $R7 - Push $R8 - Push $R9 - Push $0 - Push $1 - Push $2 - - StrCpy $R8 0 - StrCpy $R9 $R1 - - IntCmp $R0 0 0 0 +2 - StrCpy $R0 L - - - StrCmp $R0 L 0 +5 - StrCpy $2 1 - StrCpy $R0 0 - StrCpy $1 `` - StrCpy $9 1 - - PartLoop: - - StrCpy $R4 0 - IntOp $R8 $R8 + 1 - StrCpy $0 0 - - loop: - - StrCpy $R5 $R2 1 $R4 - StrCmp $R5 `` done - - StrCpy $R6 -1 - StrCpy $R7 0 loop2: + StrCpy $R3 $R0 $4 $R1 + StrCmp $R3 `` error2 + StrCmp $R3 $1 done2 + IntOp $R1 $R1 - 1 + Goto loop2 - IntOp $R6 $R6 + 1 - IntOp $R7 $R6 + 1 - StrCpy $R3 $R1 $R7 $R6 - StrCmp $R3 `` 0 +3 - IntOp $0 $0 + 1 - Goto ContLoop2 - StrCmp $R5 $R3 0 Loop2 - StrCmp $9 1 0 done - StrCmp $0 0 0 done - StrCpy $R2 $R2 `` 1 - Goto Loop - - ContLoop2: + error2: + StrCpy $R1 0 + StrCpy $R3 0 + Goto +2 - IntOp $R4 $R4 + 1 - Goto loop + done2: + StrCpy $R3 1 - done: - IntOp $R4 $R4 + $0 - StrCpy $R1 $R2 $0 - IntOp $0 $0 + 1 - StrCpy $R2 $R2 `` $0 - - StrCmp $2 1 0 +4 - StrCmp $R1 `` 0 +3 - StrCpy $R1 $1 - Goto End + StrCpy $R4 $R0 $R5 - StrCmp $R0 $R8 End - StrCmp $2 1 0 +2 - StrCpy $1 $R1 - StrCpy $R1 $R9 - Goto PartLoop - - End: + StrCmp $R1 0 +2 + StrCpy $R4 $R4 `` $R1 - StrCpy $9 $R1 + StrCmp $R3 1 0 +3 + StrCmp $R6 0 0 +2 + StrCpy $R4 $R4 `` $4 - Pop $2 - Pop $1 - Pop $0 - Pop $R9 - Pop $R8 - Pop $R7 - Pop $R6 - Pop $R5 - Pop $R4 - Pop $R3 - Pop $R2 - Pop $9 - Pop $R0 - Exch $R1 - FunctionEnd + # Center String Addition -!macroend + StrCmp $R7 0 +2 + StrCpy $R4 $R4$2 -!macro FUNCTION_STRING_StrTok_Call ResultVar StrToTokenize Separators ResultPart SkipEmptyParts + StrCpy $R1 $R5 + IntOp $R1 $R1 + $5 - !echo `$ {StrTok} "${ResultVar}" "${StrToTokenize}" "${Separators}" "${ResultPart}" "${SkipEmptyParts}"$\r$\n` + # Right String Search - Push `${StrToTokenize}` - Push `${Separators}` - Push `${ResultPart}` - Push `${SkipEmptyParts}` + loop3: - Call AdvancedStrTok + StrCpy $R3 $R0 $3 $R1 + StrCmp $R3 `` error3 + StrCmp $R3 $0 done3 + IntOp $R1 $R1 + 1 + Goto loop3 - Pop `${ResultVar}` + error3: + StrCpy $R1 0 -!macroend + done3: -!macro FUNCTION_STRING_UnStrTok_Call ResultVar StrToTokenize Separators ResultPart SkipEmptyParts + IntOp $R5 $R5 + $5 + StrCpy $R3 $R0 `` $R5 - !echo `$ {UnStrTok} "${ResultVar}" "${StrToTokenize}" "${Separators}" "${ResultPart}" "${SkipEmptyParts}"$\r$\n` + StrCmp $R1 0 +5 + IntOp $R1 $R1 - $R5 + StrCmp $R6 0 +2 + IntOp $R1 $R1 + $3 + StrCpy $R3 $R3 $R1 - Push `${StrToTokenize}` - Push `${Separators}` - Push `${ResultPart}` - Push `${SkipEmptyParts}` + StrCpy $R4 $R4$R3 - Call un.AdvancedStrTok + StrCpy $2 $R4 + Goto +2 - Pop `${ResultVar}` + Error: + StrCpy $2 `` -!macroend + # Return to User -# Function StrTrimNewLines -######################## + Pop $R5 + Pop $R4 + Pop $R3 + Pop $R2 + Pop $R1 + Pop $5 + Pop $4 + Pop $3 + Pop $R0 + Pop $R7 + Pop $R6 + Pop $0 + Pop $1 + Exch $2 -!macro FUNCTION_STRING_StrTrimNewLines + FunctionEnd - !echo `$\r$\n----------------------------------------------------------------------$\r$\nTrim New Lines Function - 2003-2004 Ximon Eighteen$\r$\n----------------------------------------------------------------------$\r$\n$\r$\n` + !macroend + + # Function StrStr + ############### - !ifdef FUNCTION_STRING_UninstSupport - !undef UnStrTrimNewLines - !define UnStrTrimNewLines `!insertmacro FUNCTION_STRING_UnStrTrimNewLines_Call` - Function un.TrimNewlines - !else - !undef StrTrimNewLines - !define StrTrimNewLines `!insertmacro FUNCTION_STRING_StrTrimNewLines_Call` - Function TrimNewlines + !macro FUNCTION_STRING_StrStr + !insertmacro STRFUNC_FUNC `StrStr` `2002-2004 Ximon Eighteen` + + Exch $R1 ; st=haystack,old$R1, $R1=needle + Exch ; st=old$R1,haystack + Exch $R2 ; st=old$R1,old$R2, $R2=haystack + Push $R3 + Push $R4 + Push $R5 + StrLen $R3 $R1 + StrCpy $R4 0 + ; $R1=needle + ; $R2=haystack + ; $R3=len(needle) + ; $R4=cnt + ; $R5=tmp + loop: + StrCpy $R5 $R2 $R3 $R4 + StrCmp $R5 $R1 done + StrCmp $R5 `` done + IntOp $R4 $R4 + 1 + Goto loop + done: + StrCpy $R1 $R2 `` $R4 + Pop $R5 + Pop $R4 + Pop $R3 + Pop $R2 + Exch $R1 + FunctionEnd + + !macroend + + # Function StrStrAdv + ################## + + !macro FUNCTION_STRING_StrStrAdv + !insertmacro STRFUNC_FUNC `StrStrAdv` `2003-2004 Diego Pedroso` + + ;Get input from user + + Exch $6 ;CaseSensitive (input) + Exch + Exch $5 ;NumLoops (input) + Exch + Exch 2 + Exch $4 ;ShowStrToSearch (input) + Exch 2 + Exch 3 + Exch $3 ;DirectionOfReturn (input) + Exch 3 + Exch 4 + Exch $2 ;DirectionOfSearch (input) + Exch 4 + Exch 5 + Exch $1 ;StrToSearch (input) + Exch 5 + Exch 6 + Exch $0 ;String (input) + Exch 6 + Push $7 ;StringLength (temp) + Push $8 ;StrToSearchLength (temp) + Push $9 ;Loop (temp) + Push $R3 ;Temp (temp) + Push $R2 ;OutVar (output) + Push $R1 ;StartCharPos (output) + Push $R0 ;EndCharPos (output) + + ; Verify if we have the correct values on the variables + ${If} $0 == `` + SetErrors ;AdvStrStr_StrToSearch not found + Goto AdvStrStr_End + ${EndIf} + + ${If} $1 == `` + SetErrors ;No text to search + Goto AdvStrStr_End + ${EndIf} + + ${If} $2 != < + StrCpy $2 > + ${EndIf} + + ${If} $3 != < + StrCpy $3 > + ${EndIf} + + ${If} $4 <> 0 + StrCpy $4 1 + ${EndIf} + + ${If} $5 <= 0 + StrCpy $5 0 + ${EndIf} + + ${If} $6 <> 1 + StrCpy $6 0 + ${EndIf} + + ; Find "AdvStrStr_String" length + StrLen $7 $0 + + ; Then find "AdvStrStr_StrToSearch" length + StrLen $8 $1 + + ; Now set up basic variables + + ${If} $2 == < + IntOp $R1 $7 - $8 + StrCpy $R2 $7 + ${Else} + StrCpy $R1 0 + StrCpy $R2 $8 + ${EndIf} + + StrCpy $9 0 ; First loop + + ;Let's begin the search + + ${Do} + ; Step 1: If the starting or ending numbers are negative + ; or more than AdvStrStr_StringLen, we return + ; error + + ${If} $R1 < 0 + StrCpy $R1 `` + StrCpy $R2 `` + StrCpy $R3 `` + SetErrors ;AdvStrStr_StrToSearch not found + Goto AdvStrStr_End + ${ElseIf} $R2 > $7 + StrCpy $R1 `` + StrCpy $R2 `` + StrCpy $R3 `` + SetErrors ;AdvStrStr_StrToSearch not found + Goto AdvStrStr_End + ${EndIf} + + ; Step 2: Start the search depending on + ; AdvStrStr_DirectionOfSearch. Chop down not needed + ; characters. + + ${If} $R1 <> 0 + StrCpy $R3 $0 `` $R1 + ${EndIf} + + ${If} $R2 <> $7 + ${If} $R1 = 0 + StrCpy $R3 $0 $8 + ${Else} + StrCpy $R3 $R3 $8 + ${EndIf} + ${EndIf} + + ; Step 3: Make sure that's the string we want + + ; Case-Sensitive Support <- Use "AdvStrStr_Temp" + ; variable because it won't be used anymore + + ${If} $6 == 1 + System::Call `kernel32::lstrcmpA(ts, ts) i.s` `$R3` `$1` + Pop $R3 + ${If} $R3 = 0 + StrCpy $R3 1 ; Continue + ${Else} + StrCpy $R3 0 ; Break + ${EndIf} + ${Else} + ${If} $R3 == $1 + StrCpy $R3 1 ; Continue + ${Else} + StrCpy $R3 0 ; Break + ${EndIf} + ${EndIf} + + ; After the comparasion, confirm that it is the + ; value we want. + + ${If} $R3 = 1 + + ;We found it, return except if the user has set up to + ;search for another one: + ${If} $9 >= $5 + + ;Now, let's see if the user wants + ;AdvStrStr_StrToSearch to appear: + ${If} $4 == 0 + ;Return depends on AdvStrStr_DirectionOfReturn + ${If} $3 == < + ; RTL + StrCpy $R0 $0 $R1 + ${Else} + ; LTR + StrCpy $R0 $0 `` $R2 + ${EndIf} + ${Break} + ${Else} + ;Return depends on AdvStrStr_DirectionOfReturn + ${If} $3 == < + ; RTL + StrCpy $R0 $0 $R2 + ${Else} + ; LTR + StrCpy $R0 $0 `` $R1 + ${EndIf} + ${Break} + ${EndIf} + ${Else} + ;If the user wants to have more loops, let's do it so! + IntOp $9 $9 + 1 + + ${If} $2 == < + IntOp $R1 $R1 - 1 + IntOp $R2 $R2 - 1 + ${Else} + IntOp $R1 $R1 + 1 + IntOp $R2 $R2 + 1 + ${EndIf} + ${EndIf} + ${Else} + ; Step 4: We didn't find it, so do steps 1 thru 3 again + + ${If} $2 == < + IntOp $R1 $R1 - 1 + IntOp $R2 $R2 - 1 + ${Else} + IntOp $R1 $R1 + 1 + IntOp $R2 $R2 + 1 + ${EndIf} + ${EndIf} + ${Loop} + + AdvStrStr_End: + + ;Add 1 to AdvStrStr_EndCharPos to be supportable + ;by "StrCpy" + + IntOp $R2 $R2 - 1 + + ;Return output to user + + Exch $R0 + Exch + Pop $R1 + Exch + Pop $R2 + Exch + Pop $R3 + Exch + Pop $9 + Exch + Pop $8 + Exch + Pop $7 + Exch + Pop $6 + Exch + Pop $5 + Exch + Pop $4 + Exch + Pop $3 + Exch + Pop $2 + Exch + Pop $1 + Exch + Pop $0 + + FunctionEnd + + !macroend + + # Function StrTok + ############### + + !macro FUNCTION_STRING_StrTok + !insertmacro STRFUNC_FUNC `StrTok` `2004 Diego Pedroso - based on StrTok by "bigmac666"` + Exch $9 + Exch + Exch $R0 + Exch 2 + Exch $R1 + Exch 3 + Exch $R2 + Push $R3 + Push $R4 + Push $R5 + Push $R6 + Push $R7 + Push $R8 + Push $R9 + Push $0 + Push $1 + Push $2 + + StrCpy $R8 0 + StrCpy $R9 $R1 + + IntCmp $R0 0 0 0 +2 + StrCpy $R0 L + + + StrCmp $R0 L 0 +5 + StrCpy $2 1 + StrCpy $R0 0 + StrCpy $1 `` + StrCpy $9 1 + + PartLoop: + + StrCpy $R4 0 + IntOp $R8 $R8 + 1 + StrCpy $0 0 + + loop: + + StrCpy $R5 $R2 1 $R4 + StrCmp $R5 `` done + + StrCpy $R6 -1 + StrCpy $R7 0 + loop2: + + IntOp $R6 $R6 + 1 + IntOp $R7 $R6 + 1 + StrCpy $R3 $R1 $R7 $R6 + StrCmp $R3 `` 0 +3 + IntOp $0 $0 + 1 + Goto ContLoop2 + StrCmp $R5 $R3 0 Loop2 + StrCmp $9 1 0 done + StrCmp $0 0 0 done + StrCpy $R2 $R2 `` 1 + Goto Loop + + ContLoop2: + + IntOp $R4 $R4 + 1 + Goto loop + + done: + IntOp $R4 $R4 + $0 + StrCpy $R1 $R2 $0 + IntOp $0 $0 + 1 + StrCpy $R2 $R2 `` $0 + + StrCmp $2 1 0 +4 + StrCmp $R1 `` 0 +3 + StrCpy $R1 $1 + Goto End + + StrCmp $R0 $R8 End + StrCmp $2 1 0 +2 + StrCpy $1 $R1 + StrCpy $R1 $R9 + Goto PartLoop + + End: + + StrCpy $9 $R1 + + Pop $2 + Pop $1 + Pop $0 + Pop $R9 + Pop $R8 + Pop $R7 + Pop $R6 + Pop $R5 + Pop $R4 + Pop $R3 + Pop $R2 + Pop $9 + Pop $R0 + Exch $R1 + FunctionEnd + + !macroend + + # Function StrTrimNewLines + ######################## + + !macro FUNCTION_STRING_StrTrimNewLines + !insertmacro STRFUNC_FUNC `StrTrimNewLines` `2003-2004 Ximon Eighteen` + + Exch $R0 + Push $R1 + Push $R2 + StrCpy $R1 0 + + loop: + IntOp $R1 $R1 - 1 + StrCpy $R2 $R0 1 $R1 + StrCmp $R2 `$\r` loop + StrCmp $R2 `$\n` loop + + IntOp $R1 $R1 + 1 + IntCmp $R1 0 no_trim_needed + StrCpy $R0 $R0 $R1 + + no_trim_needed: + Pop $R2 + Pop $R1 + Exch $R0 + FunctionEnd + + !macroend + + ;Function Calls for Install and Uninstall + + !macro FUNCTION_STRING_StrCase_Call ResultVar String Type + !verbose push + !verbose 4 + !echo `$ {StrCase} "${ResultVar}" "${String}" "${Type}"` + !verbose pop + + Push `${String}` + Push `${Type}` + Call StrCase + Pop `${ResultVar}` + !macroend + !macro FUNCTION_STRING_UnStrCase_Call ResultVar String Type + !verbose push + !verbose 4 + !echo `$ {UnStrCase} "${ResultVar}" "${String}" "${Type}"` + !verbose pop + + Push `${String}` + Push `${Type}` + Call un.StrCase + Pop `${ResultVar}` + !macroend + + !macro FUNCTION_STRING_StrClb_Call ResultVar String Action + !verbose push + !verbose 4 + !echo `$ {StrClb} "${ResultVar}" "${String}" "${Action}"` + !verbose pop + + Push `${String}` + Push `${Action}` + Call StrClb + Pop `${ResultVar}` + !macroend + !macro FUNCTION_STRING_UnStrClb_Call ResultVar String Action + !verbose push + !verbose 4 + !echo `$ {UnStrClb} "${ResultVar}" "${String}" "${Action}"` + !verbose pop + + Push `${String}` + Push `${Action}` + Call un.StrClb + Pop `${ResultVar}` + !macroend + + !macro FUNCTION_STRING_StrIOToNSIS_Call ResultVar String + !verbose push + !verbose 4 + !echo `$ {StrIOToNSIS} "${ResultVar}" "${String}"` + !verbose pop + + Push `${String}` + Call StrIOToNSIS + Pop `${ResultVar}` + !macroend + !macro FUNCTION_STRING_UnStrIOToNSIS_Call ResultVar String + !verbose push + !verbose 4 + !echo `$ {UnStrIOToNSIS} "${ResultVar}" "${String}"` + !verbose pop + + Push `${String}` + Call un.StrIOToNSIS + Pop `${ResultVar}` + !macroend + + !macro FUNCTION_STRING_StrLoc_Call ResultVar String StrToSearchFor OffsetDirection + !verbose push + !verbose 4 + !echo `$ {StrLoc} "${ResultVar}" "${String}" "${StrToSearchFor}" "${OffsetDirection}"` + !verbose pop + + Push `${String}` + Push `${StrToSearchFor}` + Push `${OffsetDirection}` + Call StrLoc + Pop `${ResultVar}` + !macroend + !macro FUNCTION_STRING_UnStrLoc_Call ResultVar String StrToSearchFor OffsetDirection + !verbose push + !verbose 4 + !echo `$ {UnStrLoc} "${ResultVar}" "${String}" "${StrToSearchFor}" "${OffsetDirection}"` + !verbose pop + + Push `${String}` + Push `${StrToSearchFor}` + Push `${OffsetDirection}` + Call un.StrLoc + Pop `${ResultVar}` + !macroend + + !macro FUNCTION_STRING_StrNSISToIO_Call ResultVar String + !verbose push + !verbose 4 + !echo `$ {StrNSISToIO} "${ResultVar}" "${String}"` + !verbose pop + + Push `${String}` + Call StrNSISToIO + Pop `${ResultVar}` + !macroend + !macro FUNCTION_STRING_UnStrNSISToIO_Call ResultVar String + !verbose push + !verbose 4 + !echo `$ {UnStrNSISToIO} "${ResultVar}" "${String}"` + !verbose pop + + Push `${String}` + Call un.StrNSISToIO + Pop `${ResultVar}` + !macroend + + !macro FUNCTION_STRING_StrRep_Call ResultVar String StringToReplace ReplacementString + !verbose push + !verbose 4 + !echo `$ {StrRep} "${ResultVar}" "${String}" "${StringToReplace}" "${ReplacementString}"` + !verbose pop + + Push `${String}` + Push `${StringToReplace}` + Push `${ReplacementString}` + Call StrRep + Pop `${ResultVar}` + !macroend + !macro FUNCTION_STRING_UnStrRep_Call ResultVar String StringToReplace ReplacementString + !verbose push + !verbose 4 + !echo `$ {UnStrRep} "${ResultVar}" "${String}" "${StringToReplace}" "${ReplacementString}"` + !verbose pop + + Push `${String}` + Push `${StringToReplace}` + Push `${ReplacementString}` + Call un.StrRep + Pop `${ResultVar}` + !macroend + + !macro FUNCTION_STRING_StrSort_Call ResultVar String CenterStr LeftStr RightStr IncludeLeftRightStr IncludeCenterStr + !verbose push + !verbose 4 + !echo `$ {StrSort} "${ResultVar}" "${String}" "${CenterStr}" "${LeftStr}" "${RightStr}" "${IncludeLeftRightStr}" "${IncludeCenterStr}"` + !verbose pop + + Push `${String}` + Push `${CenterStr}` + Push `${LeftStr}` + Push `${RightStr}` + Push `${IncludeLeftRightStr}` + Push `${IncludeCenterStr}` + Call StrSort + Pop `${ResultVar}` + !macroend + !macro FUNCTION_STRING_UnStrSort_Call ResultVar String CenterStr LeftStr RightStr IncludeLeftRightStr IncludeCenterStr + !verbose push + !verbose 4 + !echo `$ {UnStrSort} "${ResultVar}" "${String}" "${CenterStr}" "${LeftStr}" "${RightStr}" "${IncludeLeftRightStr}" "${IncludeCenterStr}"` + !verbose pop + + Push `${String}` + Push `${CenterStr}` + Push `${LeftStr}` + Push `${RightStr}` + Push `${IncludeLeftRightStr}` + Push `${IncludeCenterStr}` + Call un.StrSort + Pop `${ResultVar}` + !macroend + + !macro FUNCTION_STRING_StrStr_Call ResultVar String StrToSearchFor + !verbose push + !verbose 4 + !echo `$ {StrStr} "${ResultVar}" "${String}" "${StrToSearchFor}"` + !verbose pop + + Push `${String}` + Push `${StrToSearchFor}` + Call StrStr + Pop `${ResultVar}` + !macroend + !macro FUNCTION_STRING_UnStrStr_Call ResultVar String StrToSearchFor + !verbose push + !verbose 4 + !echo `$ {UnStrStr} "${ResultVar}" "${String}" "${StrToSearchFor}"` + !verbose pop + + Push `${String}` + Push `${StrToSearchFor}` + Call un.StrStr + Pop `${ResultVar}` + !macroend + + !macro FUNCTION_STRING_StrStrAdv_Call ResultVar String StrToSearchFor SearchDirection ResultStrDirection DisplayStrToSearch Loops CaseSensitive + !verbose push + !verbose 4 + !echo `$ {StrStrAdv} "${ResultVar}" "${String}" "${StrToSearchFor}" "${SearchDirection}" "${ResultStrDirection}" "${DisplayStrToSearch}" "${Loops}" "${CaseSensitive}"` + !verbose pop + + Push `${String}` + Push `${StrToSearchFor}` + Push `${SearchDirection}` + Push `${ResultStrDirection}` + Push `${DisplayStrToSearch}` + Push `${Loops}` + Push `${CaseSensitive}` + Call StrStrAdv + Pop `${ResultVar}` + !macroend + !macro FUNCTION_STRING_UnStrStrAdv_Call ResultVar String StrToSearchFor SearchDirection ResultStrDirection DisplayStrToSearch Loops CaseSensitive + !verbose push + !verbose 4 + !echo `$ {UnStrStrAdv} "${ResultVar}" "${String}" "${StrToSearchFor}" "${SearchDirection}" "${ResultStrDirection}" "${DisplayStrToSearch}" "${Loops}" "${CaseSensitive}"` + !verbose pop + + Push `${String}` + Push `${StrToSearchFor}` + Push `${SearchDirection}` + Push `${ResultStrDirection}` + Push `${DisplayStrToSearch}` + Push `${Loops}` + Push `${CaseSensitive}` + Call un.StrStrAdv + Pop `${ResultVar}` + !macroend + + !macro FUNCTION_STRING_StrTok_Call ResultVar String Separators ResultPart SkipEmptyParts + !verbose push + !verbose 4 + !echo `$ {StrTok} "${ResultVar}" "${String}" "${Separators}" "${ResultPart}" "${SkipEmptyParts}"` + !verbose pop + + Push `${String}` + Push `${Separators}` + Push `${ResultPart}` + Push `${SkipEmptyParts}` + Call StrTok + Pop `${ResultVar}` + !macroend + !macro FUNCTION_STRING_UnStrTok_Call ResultVar String Separators ResultPart SkipEmptyParts + !verbose push + !verbose 4 + !echo `$ {UnStrTok} "${ResultVar}" "${String}" "${Separators}" "${ResultPart}" "${SkipEmptyParts}"` + !verbose pop + + Push `${String}` + Push `${Separators}` + Push `${ResultPart}` + Push `${SkipEmptyParts}` + Call un.StrTok + Pop `${ResultVar}` + !macroend + + !macro FUNCTION_STRING_StrTrimNewLines_Call ResultVar String + !verbose push + !verbose 4 + !echo `$ {StrTrimNewLines} "${ResultVar}" "${String}"` + !verbose pop + + Push `${String}` + Call StrTrimNewLines + Pop `${ResultVar}` + !macroend + !macro FUNCTION_STRING_UnStrTrimNewLines_Call ResultVar String + !verbose push + !verbose 4 + !echo `$ {UnStrTrimNewLines} "${ResultVar}" "${String}"` + !verbose pop + + Push `${String}` + Call un.StrTrimNewLines + Pop `${ResultVar}` + !macroend + + !ifndef MUI_VERBOSE + !define MUI_VERBOSE 4 !endif - - Exch $R0 - Push $R1 - Push $R2 - StrCpy $R1 0 - - loop: - IntOp $R1 $R1 - 1 - StrCpy $R2 $R0 1 $R1 - StrCmp $R2 `$\r` loop - StrCmp $R2 `$\n` loop - - IntOp $R1 $R1 + 1 - IntCmp $R1 0 no_trim_needed - StrCpy $R0 $R0 $R1 - - no_trim_needed: - Pop $R2 - Pop $R1 - Exch $R0 - FunctionEnd - -!macroend - -!macro FUNCTION_STRING_StrTrimNewLines_Call ResultVar String - - !echo `$ {StrTrimNewLines} "${ResultVar}" "${String}"$\r$\n` - - Push `${String}` - - Call TrimNewLines - - Pop `${ResultVar}` - -!macroend - -!macro FUNCTION_STRING_UnStrTrimNewLines_Call ResultVar String - - !echo `$ {UnStrTrimNewLines} "${ResultVar}" "${String}"$\r$\n` - - Push `${String}` - - Call un.TrimNewLines - - Pop `${ResultVar}` - -!macroend - -!ifndef MUI_VERBOSE - !define MUI_VERBOSE 4 !endif diff --git a/Include/StrFunc.txt b/Include/StrFunc.txt index 32c7a2dd..3852937a 100644 --- a/Include/StrFunc.txt +++ b/Include/StrFunc.txt @@ -14,8 +14,8 @@ How to use required (required) (option1 | option2) [optional] The stars in command titles (*****) are the function usefulness in my - opinion. The more starts, the most useful it is. 5 stars (*****) is much - useful. + opinion. The more starts, the more useful it is. 5 stars (*****) is the + most useful. Any time when is mentioned "Default is" means that you can use the value mentioned or keep it blank, the result is the same. @@ -26,7 +26,25 @@ How to use If you want to add ` to a string, you should always escape it using $\` because the header file macro functions use ` to separate parameters. - 1. Include Header file + 1. Include LogicLib.nsh + ---------------------- + + !include "LogicLib.nsh" + + LogicLib.nsh has to be inside Include directory, so you don't have to + specify a path. + + You have to put this command before including the StrFunc.nsh header + file. + + Some functions from this header file depend on LogicLib. This means that + functions are less likely to have bugs and easier to understand. Extra + options from LogicLib header file do not work as most of the functions + are still using the default coding. + + Functions that use LogicLib are mentioned on their descriptions. + + 2. Include Header file ---------------------- !include "StrFunc.nsh" @@ -36,13 +54,13 @@ How to use You have to put this command before any command used in this header file. - 2. Commands + 3. Commands ----------- Some commands have special specifications to work. Consult command's - documentation on "2.3 Commands" section. + documentation on "3.3 Commands" section. - 2.1 How To Use Commands In Install Sections and Functions + 3.1 How To Use Commands In Install Sections and Functions --------------------------------------------------------- Every command used in install sections and functions have to be called @@ -52,41 +70,26 @@ How to use Example: -------- - !include "StrFunc.nsh" - ${StrStr} - - Section - - ${StrStr} $0 "OK! Now what?" "wh" - - SectionEnd - 2.2 How To Use Commands In Uninstall Sections and Functions + 3.2 How To Use Commands In Uninstall Sections and Functions ----------------------------------------------------------- Commands with Uninstall Sections and Functions support have "Un" before - the words inside brackets "{}". + the words inside curly brackets "{}". Example: -------- ${UnStrStr} - - Every command used in uninstall sections and functions have to be called - first before and out any sections and functions, without parameters, and - after the header command "${UnStrFunc}" to activate the Uninstall - sections and functions support for the commands following. - - Example: - -------- + + A complete example with both Install and Uninstall Commands: + ------------------------------------------------------------ + !include "StrFunc.nsh" ${StrStr} # Supportable for Install Sections and Functions - - ${UnStrFunc} # Command to separate commands supportable for - # Install/Uninstall sections and functions ${UnStrStr} # Supportable for Uninstall Sections and Functions @@ -95,22 +98,22 @@ How to use ${StrStr} $0 "OK! Now what?" "wh" SectionEnd - + Section Uninstall ${UnStrStr} $0 "OK! Now what?" "wh" SectionEnd - - 2.3 Commands + + 3.3 Commands ------------ ========================================================================= - **** ${StrCase} + ** ${StrCase} ------------------------------------------------------------------------- - ResultVar String Type(Lower|Upper|Title|Sentence (Case)) + ResultVar String Type(L|U|T|S|<>|"") ========================================================================= - Converts "String" to "Type" Case. + Converts "String" to "Type" Case. Uses LogicLib. Parameters: @@ -122,14 +125,15 @@ How to use Type Type of string case to convert to: - - - Lower Case (this is just an example. however this can be useful.) - - Upper Case (THIS IS JUST AN EXAMPLE. HOWEVER THIS CAN BE USEFUL.) - - Title Case (This Is Just An Example. However This Can Be Useful.) - - Sentence Case (This is just an example. However this can be - useful.) + + - L = Lower Case (this is just an example. a very simple one.) + - U = Upper Case (THIS IS JUST AN EXAMPLE. A VERY SIMPLE ONE.) + - T = Title Case (This Is Just An Example. A Very Simple One.) + - S = Sentence Case (This is just an example. A very simple one.) + - <> = Switch Case (This is just an example. A very simple one.) + - "" = Original Case (same as "String") - Default value is "Setence Case". + Default value is "" (Original Case). Result Value -> ResultVar: @@ -137,40 +141,37 @@ How to use Example: - ${StrCase} $0 "That's gonna hurt!" "Upper Case" + ${StrCase} $0 '"Você" is "You" in English.' "U" - $0 = "THAT'S GONNA HURT!" + $0 = '"VOCÊ" IS "YOU" IN ENGLISH.' ========================================================================= - **** ${StrClbSet} + * ${StrClb} ------------------------------------------------------------------------- - String + ResultVar String Action(>|<|<>|) ========================================================================= - Copy "String" to clipboard. + Makes an action with the clipboard depending on value of parameter + "Action". Uses LogicLib. Parameters: String - String to put in the clipboard. + If "Action" = ">" or "<>" - String to put on the clipboard. - ========================================================================= - **** ${StrClbGet} - ------------------------------------------------------------------------- - ResultVar - ========================================================================= - Get a string from the clipboard and return it to "ResultVar". + Action + Can be one of the following values: - Parameters: - - ResultVar - Destination where result is returned. + - ">" = Set string to clipboard. + - "<" = Get string from clipboard. + - "<>" = Swap string with clipboard's. + - "" = Cleans the clipboard. Result Value -> ResultVar: - The string found in clipboard. + If "Action" = "<" or "<>" - String found on the clipboard. ========================================================================= - ***** ${StrIOToNSIS} + *** ${StrIOToNSIS} ------------------------------------------------------------------------- ResultVar String ========================================================================= @@ -197,7 +198,7 @@ How to use $0 = "$\r$\n$\t\This is just an example\" ========================================================================= - ** ${StrLoc} + * ${StrLoc} ------------------------------------------------------------------------- ResultVar String StrToSearchFor OffsetDirection(>|<) ========================================================================= @@ -230,7 +231,7 @@ How to use $0 = "11" ========================================================================= - ***** ${StrNSISToIO} + *** ${StrNSISToIO} ------------------------------------------------------------------------- ResultVar String ========================================================================= @@ -288,10 +289,10 @@ How to use ***** ${StrStrAdv} ------------------------------------------------------------------------- ResultVar String StrToSearchFor SearchDirection(>|<) - ResultStrDirection(>|<) DisplayStrToSearch(1|0) Loops + ResultStrDirection(>|<) DisplayStrToSearch(1|0) Loops CaseSensitive ========================================================================= Searches for "StrToSearchFor" in "String" in the direction specified by - "SearchDirection" and looping "Loops" times. + "SearchDirection" and looping "Loops" times. Uses LogicLib. Parameters: @@ -321,6 +322,11 @@ How to use Number of times the code will search "StrToSearchFor" in "String" not including the original execution. Default is "0" (1 code execution). + CaseSensitive + If "1" the search will be case-sensitive (diferenciates between cases). + If "0" it is case-insensitive (does not diferenciate between cases). + Default is "0" (Case-Insensitive). + Result Value -> ResultVar: @@ -337,11 +343,12 @@ How to use When you put nothing in "String", will return an empty string and set error flag. - Example: + Example (!define LOGICLIB_STRCMP activated): - ${StrStrAdv} $0 "This is just an example" "is" "<" "<" "1" "1" + ${StrStrAdv} $0 "This IS really just an example" "IS " ">" ">" "1" "0" + "1" - $0 = "This" + $0 = "really just an example" ========================================================================= ***** ${StrRep} @@ -377,7 +384,7 @@ How to use $0 = "This is just one example" ========================================================================= - ***** ${StrSort} + *** ${StrSort} ------------------------------------------------------------------------- ResultVar String CenterStr LeftStr RightStr IncludeLeftRightStr(1|0) IncludeCenterStr(1|0) @@ -430,7 +437,7 @@ How to use $0 = "This is an exam" ========================================================================= - ***** ${StrTok} + **** ${StrTok} ------------------------------------------------------------------------- ResultVar StrToTokenize Separators ResultPart SkipEmptyParts(1|0) ========================================================================= @@ -496,21 +503,25 @@ How to use $0 = "$\r$\nThis is just an example" -Comments about functions included and not included +Functions included and not included -------------------------------------------------- -12 functions have been included - 6 were included as are in Archive - 6 were not included in Archive - StrTok (AdvStrTok) - StrLoc - StrSort (AdvStrSort) - StrCase - NSISToIO - IOToNSIS +11 functions have been included + 3 were included as are in Archive + 8 were not included in Archive + 3 were made with LogicLib coding + StrClb + StrStrAdv (AdvStrStr) + StrCase + 5 were made with normal NSIS coding + StrTok (AdvStrTok) + StrLoc + StrSort (AdvStrSort) + NSISToIO + IOToNSIS -13 functions have not been included - 10 were not included because of better functions +15 functions have not been included + 12 were not included because of better functions 6 were not included because of AdvStrTok (called here as StrTok) First String Part Function Save on Variables Function @@ -519,83 +530,40 @@ Comments about functions included and not included 2 were not included because of StrCase StrLower Function StrUpper Function + 2 were not included because of StrClb + StrClbSet Function + StrClbGet Function 1 was not included because of NSISToIO and IOToNSIS Convert / to // in Paths Function 1 was not included because of original String Replace Function (called here as StrRep) Another String Replace Function - 2 were not included because isn't useful anymore + 2 were not included because they aren't useful anymore Slash <-> Backslash Converter Function Trim Function 1 was not included because of bugs Number to String Converter Function -Comments ------------------------------------------------------------- - -Advanced Token String Function - - New function not published in Archive, much better than original StrTok, - going to replace several functions with just one. The principal idea was - based on "Save On Variables" by Afrow UK. - -Advanced String Sort Function - - New function not published in Archive, much better than original StrSort. - -Another String Replace Function - - Another doesn't mean better and simpler than the original version. - (Don't confuse the original StrRep that is in this header file with this - one) - -Convert / to // in Paths Function - - StrNSISToIO and StrIOToNSIS are better. - -First String Part Function - - AdvStrTok (called here as StrTok) is better. - -NSIS <-> Install Options String Convertor Functions - - Included from Install Options Readme. - -Number to String Converter Function - - A buggy one, needs to be remade. - -Save on Variables Function - - AdvStrTok (called here as StrTok) is better. - -Slash <-> Backslash Converter Function - - Will convert "http://www.site.com\" to "http:\\www.site.com/", not - really useful for anyone. - -Sort Strings (1, 2 and 3) Functions - - AdvStrTok (called here as StrTok), AdvStrStr (called here as StrStrAdv) - and AdvStrSort (called here as StrSort) are better. - -Split String Function - - AdvStrTok (called here as StrTok) is better. - -StrTok Function - - AdvStrTok (called here as StrTok) is better. - -Trim Function - - The real purpose of this function was to remove spaces from directory - paths, and now with the NSIS command GetFullPathName this is not useful - anymore. - Version History --------------- +1.07 - 09/21/2004 + +- LogicLib is required now, because of the remodelation of StrStrAdv, +StrCase and StrClb functions. +- Removed ${UnStrFunc} command. Now you can just include uninstall +functions commands like ${UnStrStr} to be supported by uninstall functions +and sections. +- Added case-sensitive comparation option for StrStrAdv. +- StrCase now uses System.dll which makes case convertions effective with +all latin letters (i.e. ê). +- Added switch case and original case for StrCase. +- StrClbSet and StrClbGet removed, added StrClb. +- Made compact the most usual operations inside the header file. File size +reduced. +- Added "!verbose" to header file -> faster compilation and header file +output organized (code borrowed from LogicLib.nsh). + 1.06 - 03/26/2004 - StrNumToStr removed due to complex number handling on some languages. @@ -631,7 +599,7 @@ Version History - Fixed StrTok default value for the string part. Now it's "L". - Fixed StrStrAdv fixed wrong search when had a combination of same substrings one after another in a string. -- Fixed StrLoc, when a string isn't found, don't return any value at all. +- Fixed StrLoc: when a string isn't found, don't return any value at all. 1.00 - 02/01/2004 @@ -639,8 +607,8 @@ Version History - Renamed header file to "StrFunc.nsh". - Added 1 function, StrLoc. - Modified StrStrAdv, removed some lines. -- Fixed StrTok, 2 simple numbers made it loop every time. -- Fixed some small issues in the header file. +- Fixed StrTok, 2 simple numbers made it loop everytime. +- Fixed some small issues on the header file. 0.02 - 01/24/2004 @@ -658,12 +626,13 @@ Made by Diego Pedroso (aka deguix). Functions Credits ----------------- -- Advanced Search in String, Advanced Token String, Localize in String, -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. -- NSISToIO and IOToNSIS made by Amir Szekely, Joost Verburg and Dave Laundon. +- StrCase, StrClb, StrLoc, StrSort, StrStrAdv and StrTok (Adv) made + by Diego Pedroso, some based on functions made by Dave Laundon, + "Afrow UK" and "bigmac666". +- StrRep made by Hendri Adriaens. +- StrStr, StrTrimNewLines made by Ximon Eighteen. +- StrNSISToIO and StrIOToNSIS made by Amir Szekely, Joost Verburg and + Dave Laundon. License -------