MAX SDK: String Concatenation with other variable types

MAX SDK: String Concatenation with other variable types

Anonymous
Not applicable
949 Views
2 Replies
Message 1 of 3

MAX SDK: String Concatenation with other variable types

Anonymous
Not applicable

I've been having a lot of trouble working with the string types in the max SDK:

 

as an example lets say in a loop i want to output a sequence of integers concatenated to the end of a string

 

int i = 0;

while (threadRunning){	

        STD::string s = "Hello " + STD::to_string(i); //STD::string concat
	s += "\n"; //line feed;

//convert string to character array, then store it as a CStr CStr cs(s.c_str());
//ouput to listener by finally converting it to a WStr the_listener->edit_stream->wputs(cs.ToMSTR()); the_listener->edit_stream->flush(); Sleep(1000); i++; }

I was able to make it work with that code but it feels really hacky. There must be a better way of doing this so i can avoid the STD:string object all together.

 

I spent a lot of time in the docs and could not find a simple say of concatenating an integer on to the end of the MaxString string types.

 

Please excuse me if this seems like a really noobish thing. i've only started really digging into the MAX sdk the last week or so and am having a hell of a time dealing with strings. I come from a background of mostly managed code like C# and these sorts of things have me totaly baffled.

0 Likes
950 Views
2 Replies
Replies (2)
Message 2 of 3

m_latz
Advisor
Advisor

Never done Max programming, but just read your problem ...

 

Have you tried:

 

cs.printf("Hello: %d\n", i);

 

See Max SDK Help for additional info and formatting.

 

regards

 

Markus

0 Likes
Message 3 of 3

istan
Advisor
Advisor
0 Likes