Archive: Macro for illegal characters, how to detect "space" (solved)


Macro for illegal characters, how to detect "space" (solved)
Hi all, i have written the following macro to detect spaces in a given string, but somhow it i put a space in the "illegal" characters it won't work.

Wrong code removed  


Any ideas?

Thanks
x

I hate when that happens, once you ask for help, you find out yourself.......

Quotation marks are pretty helpful once in a while, here the fixed script.

!macro _CheckforIllegalCharacters String Characters

;String String to check
;Characters List of characters with no delimiter " must be escaped $\"

StrLen $R0 "${Characters}"
StrCpy $R3 0

${FOR} $R1 0 $R0
StrCpy $R2 "${Characters}" 1 $R1
${WordFind} "${String}" "$R2" "*" $R3

${IF} $R3 > 0
;DetailPrint "Found character $R2 in ${String}"
Push $R2
${EXITFOR}
${ENDIF}
${NEXT}


!macroend
!define CheckforIllegalCharacters `!insertmacro _CheckforIllegalCharacters`

A more elegant solution: http://nsis.sourceforge.net/StrCSpn,...for_characters
I use them in a header file with macro wrappers for the calls.

Stu


Thanks, i should have know you already have something like that :D