{"id":2197,"date":"2011-03-21T14:36:30","date_gmt":"2011-03-21T18:36:30","guid":{"rendered":"http:\/\/www.gubatron.com\/blog\/?p=2197"},"modified":"2011-03-21T14:36:30","modified_gmt":"2011-03-21T18:36:30","slug":"nsis-charat-function-macro","status":"publish","type":"post","link":"https:\/\/www.gubatron.com\/blog\/nsis-charat-function-macro\/","title":{"rendered":"NSIS CharAt Macro"},"content":{"rendered":"<p>Lord knows why the NSIS folks didn&#8217;t add a CharAt function to their API.<br \/>\nIn case you need it to parse a string, here&#8217;s a Macro that makes StrCpy work like a CharAt function<\/p>\n<p>[bash]<br \/>\n;Get a character inside a string given an index.<br \/>\n;Usage: CharAt String Index Output<br \/>\n!macro CharAt InputString Index Output<br \/>\n StrCpy ${Output} ${InputString} 1 ${Index}<br \/>\n!macroend<br \/>\n[\/bash]<\/p>\n<p>To use the CharAt &#8220;function&#8221; (macro in this case), do as follows:<\/p>\n<p>[bash]<br \/>\n!insertmacro CharAt &quot;Hello World!&quot; 1 $0<br \/>\n;$0 will have the letter &#8216;e&#8217; inside.<br \/>\n[\/bash] <\/p>\n","protected":false},"excerpt":{"rendered":"<p>Lord knows why the NSIS folks didn&#8217;t add a CharAt function to their API. In case you need it to parse a string, here&#8217;s a Macro that makes StrCpy work like a CharAt function [bash] ;Get a character inside a string given an index. ;Usage: CharAt String Index Output !macro CharAt InputString Index Output StrCpy [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[15],"tags":[261,724,940,941],"class_list":["post-2197","post","type-post","status-publish","format-standard","hentry","category-code","tag-charat","tag-nsis","tag-string-manipulation","tag-strings"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p5Unzf-zr","jetpack-related-posts":[{"id":2267,"url":"https:\/\/www.gubatron.com\/blog\/nsis-strcontains-function-find-the-index-of-a-sub-string\/","url_meta":{"origin":2197,"position":0},"title":"NSIS: StrContains function &#8211; Find the index of a sub string.","author":"gubatron","date":"August 31, 2011","format":false,"excerpt":"Recently I was out of internet and I needed to implement a function that would search if a String was part of another String for an NSIS installer. Here's my rendition of such a function. Once I came back online I found out about StrStr, but here's another option that\u2026","rel":"","context":"In &quot;Code&quot;","block_context":{"text":"Code","link":"https:\/\/www.gubatron.com\/blog\/category\/code\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":2714,"url":"https:\/\/www.gubatron.com\/blog\/nsis-how-to-check-if-the-default-browser-is-chrome\/","url_meta":{"origin":2197,"position":1},"title":"NSIS: How to check if the default browser is Chrome","author":"gubatron","date":"April 28, 2012","format":false,"excerpt":"Reading the registry key won't cut it. This does. [code] ; isDefaultBrowserChrome !define isDefaultBrowserChrome \"!insertmacro isDefaultBrowserChrome\" !macro isDefaultBrowserChrome Result FileOpen $0 \"$PLUGINSDIR\\browser_detect.htm\" \"w\" FileClose $0 System::Call \"Shell32::FindExecutable(t '$PLUGINSDIR\\browser_detect.htm', i 0, t .r1)\" ${StrLoc} $0 $1 \"chrome.exe\" \">\" ${If} $0 != \"\" StrCpy ${Result} \"1\" ${Else} StrCpy ${Result} \"0\" ${EndIf} !macroend\u2026","rel":"","context":"In \"Code\"","block_context":{"text":"Code","link":"https:\/\/www.gubatron.com\/blog\/tag\/code\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":4000,"url":"https:\/\/www.gubatron.com\/blog\/what-is-the-rust-equivalent-to-javas-printwriter\/","url_meta":{"origin":2197,"position":2},"title":"What is the Rust equivalent to Java&#8217;s PrintWriter?","author":"gubatron","date":"December 21, 2022","format":false,"excerpt":"In Rust, the equivalent of Java's PrintWriter is the std::io::Write trait, which is implemented by a number of types that can be used to write data to an output stream, such as a file or a network socket. To use Write to write text to an output stream, you can\u2026","rel":"","context":"In &quot;Code&quot;","block_context":{"text":"Code","link":"https:\/\/www.gubatron.com\/blog\/category\/code\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2022\/12\/progress_image_100_7fdc7b72-6c19-42f5-affe-d055d02d6f8e.webp?fit=1024%2C1024&ssl=1&resize=350%2C200","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2022\/12\/progress_image_100_7fdc7b72-6c19-42f5-affe-d055d02d6f8e.webp?fit=1024%2C1024&ssl=1&resize=350%2C200 1x, https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2022\/12\/progress_image_100_7fdc7b72-6c19-42f5-affe-d055d02d6f8e.webp?fit=1024%2C1024&ssl=1&resize=525%2C300 1.5x, https:\/\/i0.wp.com\/www.gubatron.com\/blog\/wp-content\/uploads\/2022\/12\/progress_image_100_7fdc7b72-6c19-42f5-affe-d055d02d6f8e.webp?fit=1024%2C1024&ssl=1&resize=700%2C400 2x"},"classes":[]},{"id":1998,"url":"https:\/\/www.gubatron.com\/blog\/startkeychain-bash-utility-to-start-ssh-agent\/","url_meta":{"origin":2197,"position":3},"title":"startKeychain &#8211; bash utility to start ssh-agent","author":"gubatron","date":"June 3, 2010","format":false,"excerpt":"For my (and your) future reference, here's a function to put on your .bashrc or .bash_profile, you can invoke it later at any time to start\/re-start your ssh-agent. [bash] function startKeychain { killall ssh-agent rm ~\/.keychain\/* keychain id_rsa HOSTNAME=`hostname` source ~\/.keychain\/${HOSTNAME}-sh } [\/bash] Then at any time, the \"command\" startKeychain\u2026","rel":"","context":"In &quot;Code&quot;","block_context":{"text":"Code","link":"https:\/\/www.gubatron.com\/blog\/category\/code\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3821,"url":"https:\/\/www.gubatron.com\/blog\/bash-scripting-contains_item-bash-function-check-if-an-item-is-in-an-array\/","url_meta":{"origin":2197,"position":4},"title":"[bash scripting] `contains_item` bash function. Check if an item is in an array","author":"gubatron","date":"September 6, 2019","format":false,"excerpt":"","rel":"","context":"In &quot;Code&quot;","block_context":{"text":"Code","link":"https:\/\/www.gubatron.com\/blog\/category\/code\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":2722,"url":"https:\/\/www.gubatron.com\/blog\/add-ssh-identities-to-your-ssh-agent-when-you-start-your-bash-session\/","url_meta":{"origin":2197,"position":5},"title":"add ssh identities to your ssh agent when you start your bash session","author":"gubatron","date":"April 28, 2012","format":false,"excerpt":"Put this somewhere on your .bash_profile [bash] function addSSHIdentities() { pushd ~\/.ssh #add all your keys here ssh-add some_private_key ssh-add some_private_key_2 ssh-add some_private_key_3 ... ssh-add some_private_key_N popd } function startSSHAgent() { SSH_AGENT_PROCESSES=`ps aux | grep ssh-agent | grep -v grep | wc -l` if [ $SSH_AGENT_PROCESSES -gt 0 ] then\u2026","rel":"","context":"In \"posix\"","block_context":{"text":"posix","link":"https:\/\/www.gubatron.com\/blog\/tag\/posix\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"_links":{"self":[{"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/posts\/2197","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/comments?post=2197"}],"version-history":[{"count":0,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/posts\/2197\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/media?parent=2197"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/categories?post=2197"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.gubatron.com\/blog\/wp-json\/wp\/v2\/tags?post=2197"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}