<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<?xml-stylesheet href="_c74_vig.xsl" type="text/xsl"?>
<vignette name="The Snapshot API" package="Max" rankfactor="2">
  <h1>
The Snapshot API
</h1>
  <p>
	For advanced users and those creating standalone patchers, Snapshots can be accessed via the Snapshots API. These can be used in <link module="js" name="javascriptinmax" type="vignette">Javascript</link> with the <o>js</o> object.
</p>
  <jsmethod_list name="Snapshot">
    <jsmethod name="snapshot">
      <arglist>
        <arg name="userpath" type="String" optional="1"/>
        <arg name="index" type="Number" optional="1"/>
        <arg name="name" type="String" optional="1"/>
      </arglist>
      <description>
		    	Take a snapshot at the current index.
		    </description>
    </jsmethod>
    <jsmethod name="restore">
      <arglist>
        <arg name="index" type="Number" optional="1"/>
      </arglist>
      <description>
		    	Restore a snapshot at the given index.
		    </description>
    </jsmethod>
    <jsmethod name="addsnapshot">
      <arglist>
        <arg name="userpath" type="String" optional="1"/>
        <arg name="index" type="Number" optional="1"/>
        <arg name="name" type="String" optional="1"/>
      </arglist>
      <description>
		    	Append (no arguments) or add a snapshot at the given index.
		    </description>
    </jsmethod>
    <jsmethod name="deletesnapshot">
      <arglist>
        <arg name="index" type="Number" optional="0"/>
      </arglist>
      <description>
		    	Delete a snapshot at the given index.
		    </description>
    </jsmethod>
    <jsmethod name="getnumsnapshots">
      <arglist>
		    </arglist>
      <description>
		    	Get the total number of snapshots.
		    </description>
    </jsmethod>
    <jsmethod name="getsnapshotname">
      <arglist>
        <arg name="index" type="Number" optional="0"/>
      </arglist>
      <description>
		    	Get the name of the snapshot at the given index.
		    </description>
    </jsmethod>
    <jsmethod name="setsnapshotname">
      <arglist>
        <arg name="index" type="Number" optional="0"/>
        <arg name="name" type="String" optional="0"/>
      </arglist>
      <description>
		    	Set the name of the snapshot at the given index.
		    </description>
    </jsmethod>
    <jsmethod name="getembedsnapshot">
      <arglist>
        <arg name="index" type="Number" optional="0"/>
      </arglist>
      <description>
		    	Query the 'embed' state of a snapshot. Returns 1 if the snapshot at the index is embedded, 0 if not.
		    </description>
    </jsmethod>
    <jsmethod name="setembedsnapshot">
      <arglist>
        <arg name="index" type="Number" optional="0"/>
        <arg name="embedstate" type="Number" optional="0"/>
      </arglist>
      <description>
		    	Set the embed state of the snapshot at the index.
		    </description>
    </jsmethod>
    <jsmethod name="movesnapshot">
      <arglist>
        <arg name="srcindex" type="Number" optional="0"/>
        <arg name="dstindex" type="Number" optional="0"/>
      </arglist>
      <description>
		    	Change a snapshot's index.
		    </description>
    </jsmethod>
    <jsmethod name="exportsnapshot">
      <arglist>
        <arg name="index" type="Number" optional="0"/>
        <arg name="userpath" type="String" optional="1"/>
      </arglist>
      <description>
		    	Save a snapshot to a given file.
		  </description>
    </jsmethod>
    <jsmethod name="importsnapshot">
      <arglist>
        <arg name="index" type="Number" optional="1"/>
        <arg name="userpath" type="String" optional="1"/>
      </arglist>
      <description>
		    	Load a snapshot from a file into a given slot.
		  </description>
    </jsmethod>
  </jsmethod_list>
  <h2>Snapshot API Example</h2>
  <li>
    <openfilelink filename="snapshotAPI-example.maxpat">snapshotAPI-example.maxpat</openfilelink>
  </li>
</vignette>
