View Single Post
Old 01-08-2018, 03:39 PM   #24
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 15,721
Default

I can't see all of your code, but I think the problem your having is because of the way strings work in EEL. Strings are a bit of a second-class citizen in EEL -- variables which reference them are actually numbers which point to the string buffer.

oscSelTrackVolStr[0] through oscSelTrackVolStr[n] need to be initialized to point to distinct strings. You could do this by setting:
Code:
oscSelTrackVolStr[0] = #;
oscSelTrackVolStr[1] = #;
oscSelTrackVolStr[2] = #;
or
Code:
mem_set_values(oscSelTrackVolStr, #,#,#); // or any more # as you need
(those two syntaxes are nearly identical in function).

Which would allocate an anonymous string buffer for each, but that limit is still constant.

If you want to do it purely programmatically, you could assign the pointers to the values 0..1023 which are the user strings that you can use.
Code:
i = 0;
loop(3, 
  oscSelTrackVolStr[i] = i; i += 1; 
);
using an array in this case is actually redundant, you could just use:

Code:
oscSelTrackVolStr = 0;
...
oscparm(0,'s', oscSelTrackVolStr+trackNumber); // for track number 1, use global string index 1, track number 2 use string index 2, etc.
printf("Track Number: %d Value: %s\n",trackNumber,oscSelTrackVolStr+trackNumber);
Finally, I should mention that if possible, it's probably a good idea to avoid keeping string copies of things. E.g. if you have a string which represents a volume, convert it to a number, store that, and convert back to a string on demand.

P.S. if you want to debug what a string points to, you can use something like:
Code:
v="some string";
printf("string: %d='%s'\n", v,v);
v = #str;
printf("string: %d='%s'\n", v,v);
Justin is offline   Reply With Quote