StringReplace with a variable Topic is solved

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
bballjoe12
Posts: 114
Joined: 20 Aug 2017, 09:11

StringReplace with a variable

02 Feb 2018, 09:07

I have the following code:

Code: Select all

MsgBox, %DisplayThisText%
The %DisplayThisText% variable has text in it that includes the word 'Send.' How do I replace all instances of the word 'Send' with, let's say, with the word 'Go.' I tried looking at StringReplace but have no clue how to actually display the edited text.
User avatar
Exaskryz
Posts: 2882
Joined: 17 Oct 2015, 20:28

Re: StringReplace with a variable  Topic is solved

02 Feb 2018, 10:26

output:=StrReplace(inputVariable,"Send","Go")

Code: Select all

DisplayThisText:="Send something"
DisplayThisText:=StrReplace(DisplayThisText,"Send","Go") ; the inputVariable is the same as the output in this case, which is fine
MsgBox %DisPlayThisText%
or

Code: Select all

DisplayThisText:="Send something"
MsgBox % StrReplace(DisplayThisText,"Send","Go") ; we skip the output variable, but the result is still shown in the MsgBox using forced expression mode by using a lone % at the very start of the parameter
bballjoe12
Posts: 114
Joined: 20 Aug 2017, 09:11

Re: StringReplace with a variable

02 Feb 2018, 13:09

Awesome, got it figured out!

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: jeves and 160 guests