14 March 2011

Max/MSP Javascript "find object" - lazy dollar function

The second function in my "Making Max JS less crap" series, this function scans all objects in the patch and all subpatches and returns a reference to the object with the specified scripting name: It's basically a lazy man's version of my dollar function which means you dont need to give every patcher a scripting name. The downside is it (probably) runs a bit slower. Enjoy!

Please see right hand pane before copying my code>>

function _$(id){ //search through all max objects:
    tempobj=0
    tempname=id
    this.patcher.applydeepif (_$act,_$scan);
    delete tempname
    return(tempobj)
}
function _$act(obj){
    tempobj=obj
}
function _$scan(obj){
    if(obj.varname==tempname){
        return(true)
    }else{
        return(false)
    }
}

//USAGE:
_$("myButton").message('set','new text!') //find the first object anywhere in the project that has scripting name myButton and send it a message.

16 comments:

  1. All access to ufabet direct website, not through agents Come to here, the only place in the world, the center for direct access to UFABET. All links, a complete approach to UEFA Bet Whether it is UFABET live casino online 1 day that you all gamblers have been using the service for a long time.

    ReplyDelete
  2. Blog Site Directories-- Helpforallseo Infographic Submission is constantly functioning to build high quality back links. Select an efficient directory and also choose a correct group. It takes rather some time to deliver great outcomes, yet these results stand apart over a longer period.

    ReplyDelete
  3. thanks for sharing information with us.

    ReplyDelete
  4. This is most informative and also this post most user-friendly and super navigation to all posts. Kinemaster Gold

    ReplyDelete
  5. The content you've posted here is fantastic because it provides some excellent information that will be quite beneficial to me. Thank you for sharing that. Keep up the good work. Android App Developers in USA

    ReplyDelete
  6. Valuable information. Thanks for publishing such great information. You are doing such a great job. This information is very helpful for everyone. Keep it up. Thanks Best Msp Sales Training

    ReplyDelete
  7. Every one deserves to be happy in their family or relationships, I was lucky enough to get my husband back , Doctor Robbinson helped me he is authentic , My Husband left me for 8 months and I was devastated and couldn't find any way out to get him back i tried all ways. At some point I was depressed, while i was reading through some post on the internet where people testified about how Dr Robbinson helped them Solve similar problems I contacted him and he never hesitated to help me as well, My husband is back home, my happiness is restored
    Text/call: +12267705795
    Email: Drrobbinssonspiritualhome@gmail.com

    ReplyDelete
  8. I read the above article and got some knowledge from your article which is about..... It's actually great and useful data for us. Thanks for sharing it.web development

    ReplyDelete
  9. This is a great article you've shared because it offers some great information that will be very helpful to me. I'm grateful that you said that. Work well done; continue.artificial intelligence

    ReplyDelete
  10. I read the article you linked to above, and I learned a little something from it. For us, the information is genuinely quite good and helpful. We appreciate you sharing it.hire programmers in india

    ReplyDelete
  11. We've noticed that this article is well-informed, in my opinion. The essay is beneficial to us, and your writing is exceptional. We appreciate you sharing this content.hire coldfusion developers

    ReplyDelete
  12. Enterprise Risk Management Software assists in tracking and managing compliance with industry regulations and standards, reducing regulatory risks.

    ReplyDelete
  13. This is a great article you've shared because it offers some great information that will be very helpful,keep posting.
    python training in kukatpally

    ReplyDelete