Loading Max Files

Several high-level functions permit you to load patcher files. More...

+ Collaboration diagram for Loading Max Files:

Functions

short readtohandle (C74_CONST char *name, short volume, char ***h, long *sizep)
 Load a data file into a handle. More...
 
void * fileload (C74_CONST char *name, short vol)
 Load a patcher file by name and volume reference number. More...
 
void * intload (C74_CONST char *name, short volume, t_symbol *s, short ac, t_atom *av, short couldedit)
 Pass arguments to Max files when you open them. More...
 
void * stringload (C74_CONST char *name)
 Load a patcher file located in the Max search path by name. More...
 

Detailed Description

Several high-level functions permit you to load patcher files.

These can be used in sophisticated objects that use Patcher objects to perform specific tasks.

Function Documentation

void* fileload ( C74_CONST char *  name,
short  vol 
)

Load a patcher file by name and volume reference number.

Parameters
nameFilename of the patcher file to load (C string).
volPath ID specifying the location of the file.
Returns
If the file is found, fileload tries to open the file, evaluate it, open a window, and bring it to the front. A pointer to the newly created Patcher is returned if loading is successful, otherwise, if the file is not found or there is insufficient memory, zero is returned.
void* intload ( C74_CONST char *  name,
short  volume,
t_symbol s,
short  ac,
t_atom av,
short  couldedit 
)

Pass arguments to Max files when you open them.

This function loads the specified file and returns a pointer to the created object. Historically, intload() is was used to open patcher files, whether they are in text or Max binary format. It could also open table files whose contents begin with the word "table".

Parameters
nameName of the file to open.
volumePath ID specifying the location of the file.
sA symbol.
acCount of t_atoms in av. To properly open a patcher file, ac should be 9.
avArray of t_atoms that will replace the changeable arguments 1-9. The default behavior could be to set all these to t_atoms of type A_LONG with a value of 0.
couldeditIf non-zero and the file is not a patcher file, the file is opened as a text file.
Returns
If couldedit is non-zero and the file is not a patcher file, it is made into a text editor, and intoad() returns 0. If couldedit is non-zero, intload() will alert the user to an error and return 0. If there is no error, the value returned will be a pointer to a patcher or table object.
short readtohandle ( C74_CONST char *  name,
short  volume,
char ***  h,
long *  sizep 
)

Load a data file into a handle.

This is a low-level routine used for reading text and data files. You specify the file's name and Path ID, as well as a pointer to a Handle.

Parameters
nameName of the patcher file to load.
volumePath ID specifying the location of the file.
hPointer to a handle variable that will receive the handle that contains the data in the file.
sizepSize of the handle returned in h.
Returns
If the file is found, readtohandle creates a Handle, reads all the data in the file into it, assigns the handle to the variable hp, and returns the size of the data in size. readtohandle returns 0 if the file was opened and read successfully, and non-zero if there was an error.
void* stringload ( C74_CONST char *  name)

Load a patcher file located in the Max search path by name.

This function searches for a patcher file, opens it, evaluates it as a patcher file, opens a window for the patcher and brings it to the front. You need only specify a filename and Max will look through its search path for the file. The search path begins with the current 'default volume' that is often the volume of the last opened patcher file, then the folders specified in the File Preferences dialog, searched depth first, then finally the folder that contains the Max application.

Parameters
nameFilename of the patcher file to load (C string).
Returns
If stringload() returns a non-zero result, you can later use freeobject() to close the patcher, or just let users do it themselves. If stringload() returns zero, no file with the specified name was found or there was insufficient memory to open it.
  Copyright © 2015, Cycling '74