I know a simular question has been asked before here:
How to concatenate a number and a string in auto hotkey
But this question only takes numbers into account. My problem is a bit different. For example:
myStr = A literal string
myInt = 5
Now I wish to concatenate both into a new string: 5A literal string
This is what I've tried so far:
newStr = %myInt%%myStr% ;Result: Error illegal character found
newStr = % myInt myStr ;Result: Some number
convertString = (%myInt% . String)
newStr = %convertString%%myStr% ;Result: Error illegal character found
It seems like no matter what I try, AHK just can't handle concatenating an integer with a textstring. Has anyone experience with this and know a way to get it working?
EDIT
I should add that I can't solve the issue by doing myInt = "5"
as I need to operate on the integer in a loop with myInt++
. Also a second question that I haven't figured out yet is: How to add unicode to the string? I thought it was U+0003
, but that doesn't seem to work.
EDIT 2
It seems someone else isn't getting the same results. I've updated AHK but the problems remains. So I'll be including my exact code here, perhaps I'm doing something wrong?
global OriText ;Contains textstring
global NewText ;Empty
global ColorNumber
ColorNumber = 2
convert_text(){
StringSplit, char_array, OriText
Loop, %char_array0%
{
thisChar := char_array%a_index%
NewText += % ColorNumber thisChar
MsgBox, %NewText%
ColorNumber++
if (ColorNumber = 13){
ColorNumber = 2
}
}
GuiControl,, NewText, %NewText%
ColorNumber = 2
}
Short explanation: I'm building a little tool that will automaticly colorize text in irc adding a different color to each character. Therefor splitting the string into an array and trying to add:
U:0003ColorNumberCharacter
Where U:0003 should be the unicode for the character used in mIRC with (Ctrl+K).