Forums > Javascript

getlogical() substitute, apply() – can't exit early

December 2, 2012 | 11:09 pm

In needing a work around for the getlogical() function that crashes Max6 (http://cycling74.com/forums/topic.php?id=43958), I’ve started using apply() which is doing the job with one hitch: It says it needs to return true to continue iterations, but when I try to return a false to end early (a patcher with a lot of objects to check every time) it doesn’t exit. The sample code is:
function printobj(a)
{
post(a.maxclass);
post();
return true;
// iterfun must return true to continue
// iterating, else stops
}
this.patcher.apply(printobj);

from: http://cycling74.com/docs/max5/vignettes/js/jspatcherobject.html

I’d like to jump out early upon finding my object if possible.

This also makes me wonder what the real difference is between apply() and getlogical(). Is one there for legacy support?

If it makes it any clearer (hard to imagine with my coding) here’re the patchers and javascript I’m working with. These are for testing this capability. This uses the mouse, but it’s for a touch screen which is why I’m not just using the hover object.

Thanks for any help!
Andrew


December 2, 2012 | 11:15 pm

…and the files

Attachments:
  1. MaxApplyTest.zip

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