array of numbers as labels

Discuss problems and solutions.
Post Reply
electrofux
Regular
Posts:297
Joined:24 Jan 2012 18:22
array of numbers as labels

Post by electrofux » 29 Sep 2014 15:20

Hello,

i have an array Oneto16={1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16}
and i want to use it to set the labels of a padobject (the array changes dynamically).

But setattribute(padobject,'labels',Oneto16} doesnt work. Probably because the elements aren't strings.
How should a go about this to make it work?

Softcore
Regular
Posts:1639
Joined:04 Nov 2012 08:34

Re: array of numbers as labels

Post by Softcore » 29 Sep 2014 15:43

{'1','2',.......'16'}

;)

electrofux
Regular
Posts:297
Joined:24 Jan 2012 18:22

Re: array of numbers as labels

Post by electrofux » 29 Sep 2014 15:59

yeah, but the values in the array change and so should the labels- that is the problem. If make the array strings from the start i lose the possibilty to change the numbers by adding/multiplying the values.
I think ineed some sort of conversion to strings but with array to string i didnt get far.

Softcore
Regular
Posts:1639
Joined:04 Nov 2012 08:34

Re: array of numbers as labels

Post by Softcore » 29 Sep 2014 16:11

Ohhh I get it now....then use

decl i,k
for (i=0;i<sizeof(Oneto16);i++){
k=''+Oneto16;
}

and then use k instead of Oneto16

electrofux
Regular
Posts:297
Joined:24 Jan 2012 18:22

Re: array of numbers as labels

Post by electrofux » 29 Sep 2014 16:14

Ahhh nice, this works. Thx.

Softcore
Regular
Posts:1639
Joined:04 Nov 2012 08:34

Re: array of numbers as labels

Post by Softcore » 29 Sep 2014 16:29

As of Lemur 5 with string concatenation (or what was that called lol) you can make any number-array into a string by simply adding an empty string value before it....

so for example if

k=1;

''+k = '1'

;)

Post Reply