Translate

NSIS CharAt Macro

Lord knows why the NSIS folks didn’t add a CharAt function to their API.
In case you need it to parse a string, here’s a Macro that makes StrCpy work like a CharAt function

;Get a character inside a string given an index.
;Usage: CharAt String Index Output
!macro CharAt InputString Index Output
 StrCpy ${Output} ${InputString} 1 ${Index}
!macroend

To use the CharAt “function” (macro in this case), do as follows:

!insertmacro CharAt "Hello World!" 1 $0
;$0 will have the letter 'e' inside.
Digg This
Reddit This
Stumble Now!
Buzz This
Vote on DZone
Share on Facebook
Bookmark this on Delicious
Kick It on DotNetKicks.com
Shout it
Share on LinkedIn
Bookmark this on Technorati
Post on Twitter
Google Buzz (aka. Google Reader)

Leave a Reply