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

Dec 2, 2012 at 11:09pm

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

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

#65462
Dec 2, 2012 at 11:15pm

…and the files

Attachments:
  1. MaxApplyTest.zip
#235883

You must be logged in to reply to this topic.