Variables, Constants, Send/Receive, etc.

    Apr 19 2013 | 3:16 pm
    I apologize if I'm just terminally thick, but I'm drawing a total blank at this moment, and exhaustive searching has mostly led to similar unanswered questions, or external/js-related solutions
    How does one define a variable/constant, etc., which in traditional languages might be:
    int TransposeVal = 12
    within Max, such that this variable/constant can then be accessed within other patchers/sub-patchers, without a patch cord to every instance? I suppose send/receive can do that, but from what I gather, there is a high cpu cost vs. patch cords, at least in m4l.
    At this stage, even the ability to create named global constants, which could be recognized by Max objects, would be a godsend.
    This is one of the fundamental tasks in any programming environment, and I assume there has to be an analog here, but I'm just too blind to see it, I guess...
    Thanks so much for any insight.

    • Apr 19 2013 | 3:26 pm
      Look at objects [value] and [pattr]
    • Apr 19 2013 | 4:21 pm
      Yeah, that's pretty much the ticket. Thanks, man. So... before I retire to the corner w/ my dunce cap, humor me for a second...
      Open your Max 6 help, and type "variable" or "constant" in the search string. Do you get anything even close to value, pattr, pv, etc. in your results?
      I don't. But if I knew to look at the [value] reference, the text "variable" is certainly in there a few times.
      Now do a search on this forum for "variable". OK, it's a common word, but after pages & pages of results, no reference to anything like these objects that I could find. Try Google for "max msp variables" & similar, etc. Still no reference to these objects.
      Look, I'm one of those perverse individuals that actually does RTFM, and confess to enjoying reading manuals. But a manual has to have a table of contents, index, be a searchable pdf, etc., for it to be really useful to most folks. I'm not talking about the HELP system, which is wicked cool, if you already have an idea what you're looking for. But is there a SEARCHABLE Max reference document somewhere that I missed?
      If not, why?
      Back on topic, if these types of "wireless" objects are only initialized with a value once at patcher load, does anyone know if the values, of say, a [value] object are stored "locally", i.e., reading the value is no more cpu intensive than reading the value of a [message], etc?
      Thanks again.
    • Apr 19 2013 | 5:21 pm
      It's because you just simply don't use the concept of "variables" very often in Max. It's a different kind of programming language. If you approach it like you would approach Java or other non-visual languages you're probably going to hit more hurdles than if you treat it as an entirely different beast.
      And the latency for send and receive in M4L is only a problem for signals, not messages. If you're passing an int around you should have zero problem with using send and receive in M4L even between devices.
    • Apr 19 2013 | 5:31 pm
      I'm trying to learn to "think in Max", really I am :-)
      re: the latency, that's very good news. What I'm doing is 90% MIDI/Live API control at this stage.
      If my post sounds at all nit-picky, understand that I'm completely blown away by the capabilities of this environment. I've come to accept that if I'm not able to accomplish something in Max, it's almost certainly because I haven't looked hard enough.
      But I STILL think it's screaming out for a full-text searchable help system ;-)