Why does this string concatenation work?


#1

in this line i get a compiler error: - "invalid operands char[129] and ‘const char[2]’ t binary [operator+’ "

          m  =  findItemByText(prog.multiName+":"+STRING(prog.multiChannelMIDIChannel) ,idx );

prog.multiname is just a string and prog.multiChannelMIDIChannel is just an int.

how can i get this to compile ? isn’t it possible to do such simple concatenations with JUCE strings ?


#2

What’s STRING()?


#3

just a macro for Juce::String


#4

Of course it is possible with JUCE…
Is your prog.multiname a juce::String…? And your first argument in findItemByText() is a juce::String as well…?

I don’t still understand the STRING macro that you have used… I hope it is simply juce::String(prog.multiChannelMIDIChannel) as it will work nicely for integers…

Try to concatenate into a temp String first and then pass it into your function (just to solve it)… I hope you’ll find out the error…


#5

Yuck! If you’re really too lazy to type it out, you should at least use a typedef, never a macro!

And according to your error message, prog.multiname is a char*, so you should make it a String instead.


#6

Yuck! If you’re really too lazy to type it out, you should at least use a typedef, never a macro!

And according to your error message, prog.multiname is a char*, so you should make it a String instead.[/quote]

yeah youre right abt macros - mea culpa ! will change that eventually…

And yes - turned out multiname is a char[] string in a struct - id’ confused it with another property of the same name which IS a Juce::String and thus missed this.

Thanks