Please help - how to use StrReplace() with variables?

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
user344344863

Please help - how to use StrReplace() with variables?

21 Feb 2018, 14:28

Hello,

I am making a program which will replace parts of inputed text with another.
The point is that text which is going to be replaced is stored in a variable and text to replace with is stored in variable too.
I have this code:

Code: Select all

ReturnText := StrReplace(InputText, %KeyA%, %KeyB%)
where KeyA is variable with text which is going to be replaced and KeyB is variable to replace the text with.
For example:
When I input "AutoHotkey" and KeyA = o, KeyB = q,
I was expecting it to output "AutqHqtkey".
I tried it but it didn´t work...
BoBo
Posts: 6564
Joined: 13 May 2014, 17:15

Re: Please help - how to use StrReplace() with variables?

21 Feb 2018, 14:55

Code: Select all

InputText := "AutoHotkey"
KeyA := "o"
KeyB := "q"
MsgBox % ReturnText := StrReplace(InputText, KeyA, KeyB)
Not tested. :arrow: Expressions

Return to “Ask for Help (v1)”

Who is online

Users browsing this forum: doodles333, Google [Bot], onurcoban and 361 guests