<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet href="_c74_vig.xsl" type="text/xsl"?>
<vignette name="Basic Javascript Programming: The Max Object" package="Max" rankfactor="3">
  <h1>The Max Object</h1>
  <p>
		The Max object can be accessed as a property of a <b>jsthis</b> object (see <b>jsthis</b> Properties in the <link type="vignette" module="js" name="jsmaxobj">Global Methods</link> Guide). It is intended to provide control over the application environment.
	</p>
  <jsproperty_list name="Max">
    <jsproperty name="apppath" get="1" set="0" type="String">
      <description>
				The pathname of the Max application
        	</description>
    </jsproperty>
    <jsproperty name="arch" get="1" set="0" type="String">
      <description>
					The currently running Max architecture ('x64' or 'x86').
        	</description>
    </jsproperty>
    <jsproperty name="frontpatcher" get="1" set="0" type="Patcher">
      <description>
				The Patcher object of the frontmost patcher window, or a nil value if no patcher window is visible. You can traverse the list of open patcher windows with the next property of a Wind object.
        	</description>
    </jsproperty>
    <jsproperty name="isplugin" get="1" set="0" type="Number">
      <description>
				1 if the <o>js</o> object is within a plug-in; note that this would be 1 if the <o>js</o> object was within a plug-in loaded into the vst~ object in Max.
        	</description>
    </jsproperty>
    <jsproperty name="isruntime" get="1" set="0" type="Number">
      <description>
				1 if the currently executing Max application environment does not allow editing, 0 if it does.
        	</description>
    </jsproperty>
    <jsproperty name="loadbangdisabled" get="1" set="0" type="Number">
      <description>
				1 if the user has disabled loadbang for the currently loading patch. If your object implements a loadbang method, it can test this property and choose to do nothing if it is true.
        	</description>
    </jsproperty>
    <jsproperty name="os" get="1" set="0" type="String">
      <description>
				  The name of the platform (e.g., “windows” or “macintosh”)
        	</description>
    </jsproperty>
    <jsproperty name="osversion" get="1" set="0" type="String">
      <description>
				  The current OS version number.
        	</description>
    </jsproperty>
    <jsproperty name="time" get="1" set="0" type="Number">
      <description>
				The current scheduler time in milliseconds - will be a floating-point value.
        	</description>
    </jsproperty>
    <jsproperty name="version" get="1" set="0" type="String">
      <description>
				The version of the Max application, in the following form: "451"
        	</description>
    </jsproperty>
  </jsproperty_list>
  <jsproperty_list name="Max Modifier Key">
    <jsproperty name="cmdkeydown" get="1" set="0" type="Number">
      <description>
				  1 if the command (Macintosh) or control (Windows) key is currently held down
        	</description>
    </jsproperty>
    <jsproperty name="ctrlkeydown" get="1" set="0" type="Number">
      <description>
				  1 if the control key is currently held down
        	</description>
    </jsproperty>
    <jsproperty name="optionkeydown" get="1" set="0" type="Number">
      <description>
				1 if the option (Macintosh) or alt (Windows) key is currently held down
        	</description>
    </jsproperty>
    <jsproperty name="shiftkeydown" get="1" set="0" type="Number">
      <description>
				1 if the shift key is currently held down
        	</description>
    </jsproperty>
  </jsproperty_list>
  <jsmethod_list name="Max">
    <jsmethod name="getattrnames">
      <arglist />
      <description>
          Returns an Array value containing the names of available attributes for the object.
      </description>
    </jsmethod>
    <jsmethod name="getattr">
      <arglist>
        <arg name="attribute_name" type="string"/>
      </arglist>
      <description>
          Returns the value of the attribute specified by <m>attribute_name</m>. Lists are returned as JS Array objects.
      </description>
    </jsmethod>
    <jsmethod name="setattr">
      <arglist>
        <arg name="attribute_name" type="string"/>
        <arg name="anything" type="string"/>
      </arglist>
      <description>
          Sets the value of the attribute specified by <m>attribute_name</m>.
      </description>
    </jsmethod>
  </jsmethod_list>
  <h2>Max Methods</h2>
  <p>
		The Max object can be accessed as a property of a <b>jsthis</b> object (see <b>jsthis</b> Properties above). Any message you can send to the max object using the semicolon notation in a message box can be invoked within Javascript using Javascript syntax. For example, the following in a message box:
	</p>
  <code>
		; max preempt 1
	</code>
  <p>
		This can be expressed in Javascript as:
	</p>
  <code language="javascript">
		max.preempt(1);
	</code>
  <p>
		For a list of current messages that can be sent to the Max object, refer to the <link type="vignette" module="core" name="messages_to_max">Messages to Max</link> Guide.
	</p>
</vignette>
