Discuss Lemur and share techniques.
GV1
Newbie
Posts: 38 Joined: 03 Jan 2012 19:33
Post
by GV1 » 18 Oct 2016 20:27
How can I display an integer in a text object?
The following example doesn't work:
Code: Select all
decl val = 9;
setattribute(OctaveLabel.octaveValue, 'content', val);
But if I do the following it works fine:
Code: Select all
setattribute(OctaveLabel.octaveValue, 'content', '5');
oldgearguy
Regular
Posts: 315 Joined: 02 Nov 2013 11:19
Post
by oldgearguy » 18 Oct 2016 20:40
try this:
Code: Select all
decl val = 9;
setattribute(OctaveLabel.octaveValue, 'content', ''+val);
outside the box man, outside the box.
MrCorba
Regular
Posts: 142 Joined: 02 Sep 2013 20:17
Location: Netherlands
Post
by MrCorba » 18 Oct 2016 20:42
You'll have to concatenate the integer and an empty string and this will turn the value into a string. Like this
Code: Select all
decl val = 9;
setattribute(OctaveLabel.octaveValue, 'content', '' + val);
It's not optimal but once you know it it's easy to work around it.
Ah damn, oldgearguy beat me to it
GV1
Newbie
Posts: 38 Joined: 03 Jan 2012 19:33
Post
by GV1 » 18 Oct 2016 20:43
oldgearguy wrote: try this:
Code: Select all
decl val = 9;
setattribute(OctaveLabel.octaveValue, 'content', ''+val);
outside the box man, outside the box.
I tried that, it didn't work. Really odd. Unless this is only available in newer updates.
GV1
Newbie
Posts: 38 Joined: 03 Jan 2012 19:33
Post
by GV1 » 18 Oct 2016 20:51
Only other thing I can think of is use a monitor object, make it transparent and put a black empty text object over monitor. Urgh. Hackish if I have to do that.
oldgearguy
Regular
Posts: 315 Joined: 02 Nov 2013 11:19
Post
by oldgearguy » 18 Oct 2016 21:54
GV1 wrote: oldgearguy wrote: try this:
I tried that, it didn't work. Really odd. Unless this is only available in newer updates.
I forgot you were on original hardware. Does this work?
Code: Select all
decl val={0x39};
setattribute (Label, 'content', arraytostring(val));
If it does, that means you'll have to do more math to add 0x30 to each decimal place and do the division to break down the raw number.
oldgearguy
Regular
Posts: 315 Joined: 02 Nov 2013 11:19
Post
by oldgearguy » 18 Oct 2016 22:20
Here's a quick and dirty way to take a number and array-ify it. You'll probably want to make it more elegant, but you get the idea:
Code: Select all
decl val, tmp;
decl num=4819, i=0, remain;
while (num > 0) {
remain = num % 10;
tmp[i++] = remain + 0x30;
num = floor(num / 10);
}
i--;
while (i >= 0)
val[sizeof(tmp) - i - 1] = tmp[i--];
setattribute (Label, 'content', arraytostring(val));
GV1
Newbie
Posts: 38 Joined: 03 Jan 2012 19:33
Post
by GV1 » 18 Oct 2016 23:17
Thanks. I was thinking about doing this. Will give it a shot tomorrow.
GV1
Newbie
Posts: 38 Joined: 03 Jan 2012 19:33
Post
by GV1 » 19 Oct 2016 09:27
Testing now. I'm not sure how I can make it more elegant except to contain it in a function ... that's a solid solution to be honest.
GV1
Newbie
Posts: 38 Joined: 03 Jan 2012 19:33
Post
by GV1 » 19 Oct 2016 10:02
Works
Code: Select all
setattribute(testTxt, 'content', Helpers.intToString(49));
Thanks!