Classes


Last modified: 2012-12-5

Class Global

The Global object is a fairly generic Javascript object that allows you to share data among js instances by adding and accessing properties. You can also access Global object properties from Max messages completely outside of js. Executing methods stored in Global objects from Max is not supported. However, methods are certainly among the kinds of things you can store within a Global object.

Global in Cycling '74 Reference

Class Summary
Constructor Attributes Constructor Name and Description
 
Global(name)
The Global object is a fairly generic Javascript object that allows you to share data among js instances by adding and accessing properties.
Field Summary
Field Attributes Field Name and Description
abstract mixed 
There are no fixed properties for a Global object.
Method Summary
Method Attributes Method Name and Description
void 
sendnamed(receive_name, property_name)
Sends the value of the named property property_name to the named Max receive object (or other Max object) bound to the specified receive_name symbol.
Class Detail

Global

(name)
The Global object is a fairly generic Javascript object that allows you to share data among js instances by adding and accessing properties. You can also access Global object properties from Max messages completely outside of js. Executing methods stored in Global objects from Max is not supported. However, methods are certainly among the kinds of things you can store within a Global object.

A Global is basically a reference to a Javascript object that you can't access directly. The object is connected to the Max symbol with the name you supplied as an argument (this allows it to be accessed from Max). Every time you access a Global, it hands off the access to the secret hidden Javascript object. This means you can create any number of Global objects in your code, in any number of js instances, and if they all have the same name, they will all share the same data. In this way, a Global resembles a namespace.

There are no fixed properties for a Global object. Instead, you assign properties to a Global object (see example) so that they can be accessed by multiple js object instances.

Accessing the Global Object from Max

To use Max to send a message to a named object, type a semicolon followed by the name of the receiver and the message you want to send into a message box. To set a property of a js Global object, send the property name followed by one or more values (multiple values set the value of the property to an array). Assuming you have already created a Global xyz object...

This sets the value of the george property to 30.
; xyz george 30
This sets the value of the frank property to an array of three strings containing "x" "y" and "z"
; xyz frank x y z
You can also use the message sendnamed from Max to output property values to named receive objects. This sends the current value of the frank property in the js Global object xyz to any receive objects named hubert.
; xyz sendnamed hubert frank
Note a subtle distinction. When setting property values using Max, the Javascript properties are changed but no further action happens. When using sendnamed(), receive objects take action and output the property values.
Example:
g = new Global("name");
g.bob = 12;

h = new Global("name");

// will print 12
post(h.bob);
Parameters:
{String} name
name represents a String that uniquely identifies the Global.
 
Field Detail
{abstract mixed}

you_define_it

There are no fixed properties for a Global object. Instead, you assign properties to a Global object so that they can be accessed by multiple js object instances.
Example:
g = new Global("name");
g.bob = 12;

h = new Global("name");

// will print 12
post(h.bob);
Method Detail
{void}

sendnamed

(receive_name, property_name)
Sends the value of the named property property_name to the named Max receive object (or other Max object) bound to the specified receive_name symbol.
Example:
g = new Global("xyz");
g.ethyl = 1000;

// Any receive objects named fred will send 1000 out their outlets.
g.sendnamed("fred","ethyl");
Parameters:
{String} receive_name
varname of a Maxobj (or scripting name of an object in a patcher)
{String} property_name
property name of this global object
 

©2012-2013
Max MSP Documentation copied to JsDoc by Tim Schenk SEO Frelancer Berlin. Some examples are by him. Some descriptions of classes, interfaces, properties, methods or events are by him. Until now, most of it is a copy. Published with permission of Cycling '74. This document might be wrong or incomplete. All informations without any warranty. All trademarks are the property of their respective owners. Documentation generated by JsDoc Toolkit on 2012-12-5