Forums > Javascript

string.length

February 1, 2011 | 5:08 pm

Why does this return a tring length of 1?

function bang()
{
api = new LiveAPI(this.patcher, "live_set tracks 0 clip_slots 0 clip");
var CLIPNAME=api.get("name");
var TEST=CLIPNAME.length;

post (TEST);
}

Thank you.


February 1, 2011 | 6:06 pm

That heavily depends on the contents of the clipslot you mention. For example; for all we know it could contain a clip which is named "1".


February 1, 2011 | 7:23 pm

I believe you are parsing the length of an ARRAY, as that is what the API returns as a result of get(‘name’). Try var TEST=CLIPNAME.join().length instead, I think that will work.

Cheers.


February 2, 2011 | 12:32 pm

Yes, that works. Thank you very much amourna.

Ok, I’ll move on with my patch till the next hurdle. :)


Viewing 4 posts - 1 through 4 (of 4 total)