## Re: Converting numeric text data collected from listbox to a matrix

Community Trekker

Joined:

Jul 1, 2016

The list data below (LotSlot_Start) was extracted from a list box in an app I am creating. I am trying to turn it into a matrix with of form [14, 13].  The below gives me what I want, but I want to be able to do it for any number of entries.

``````LotSlot_Start = {"14", "13"};
//This gives me what I want: slot_start = [14, 13]
Slot_Start=Matrix(num(lotslot_start[1]));
Slot_Start=v concat(slot_start,Matrix(num(lotslot_start[2])));

show(Slot_Start);``````

I have created this script:

``````//This crashes jmp and I can't figure out why
for(i=1, i=nitems(lotslot_start), i++,
If(i==1, Slot_Start=Matrix(num(lotslot_start[i])));
If(i>1, Slot_Start=v concat(slot_start,Matrix(num(lotslot_start[i]))));
);

show(Slot_Start);``````

But it always crashes JMP when I try to run it.  I can't figure out why.  Any help would be appreciated.

Thanks,

1 ACCEPTED SOLUTION

Accepted Solutions

Community Trekker

Joined:

Sep 30, 2016

Solution

That is what I get for getting distracted before hitting send.  Glad you figured it out..

3 REPLIES
Highlighted

Community Trekker

Joined:

Jul 1, 2016

Nevermind I figured out what the issue was I forgot the '<' when defining the range of i, 'i<=nitems()'

Community Trekker

Joined:

Sep 30, 2016

The second argument of the for loop needs to less than or equal to, right now it is false for the first value of i.

``for(i=1, i<=nitems(lotslot_start), i++,``

Community Trekker

Joined:

Sep 30, 2016

Solution

That is what I get for getting distracted before hitting send.  Glad you figured it out..