The API supports several functions which are available from C as well as C++. All are available from OpenAlias, and some are available in OpenModel as well (with reduced functionality).
void AlPrintf( AlOutputType ot, const char* fmt, ... ); void AlVprintf( AlOutputType ot, const char* fmt, va_list ap );
These functions work like printf() but can output to the prompt line or the errlog file. This function is available to OpenModel and OpenAlias, however in OpenModel kErrlog, kPrompt, and kPromptNoHistory output to stdout.
statusCode AlFileBrowser( AlFileBrowseMode mode, char **returnFilename, const char *acceptString, boolean showSample, const char *fileExtension )
Prompts the user with a file browser to select a filename. Note that the fileExtension field is currently unimplemented and has no effect (this may be implemented in the future). This function is not available in OpenModel.
char *filename; statusCode stat = AlFileBrowser( kFileBrowseRead, &filename, "Load", FALSE, NULL ); AlPrintf( kPrompt, "You selected %s.", filename ); free (filename);
const char* AlInvokeSchemeFile( char * fname, const char *dirName );
This function causes the named Scheme file to be run. This is most often done in the plugin_init() function of a plug-in to cause the initial values for option box variables to be set. This function is not available in OpenModel.
const char *AlInvokeSchemeCommand( const char *command );
This function causes the given scheme command to be invoked.
statusCode AlGetInteger( const char * name, int& value ); statusCode AlGetDouble( const char * name, double& value ); statusCode AlGetString( const char * name, const char *& value );
These functions get the value of the given Scheme variable. sSuccess is returned if the value was successfully returned. These functions are not available in OpenModel.
statusCode AlSetInteger( const char * name, int value ); statusCode AlSetDouble( const char * name, double value ); statusCode AlSetString( const char * name, const char * value );
These functions set the value of the given Scheme variable. sSuccess is returned if the value was successfully returned. These functions are not available in OpenModel.
These functions can be used in a init_option_function that will be described in the section on "General Option Box Attributes" for setting values in the option box before it is displayed.
boolean AlIsValid( AlObject* obj );
This is the central function to call to check that a given OpenAlias pointer references a valid object. Three checks will be performed - the first is done here, and simply checks that the pointer is non-null. The other two checks are done in the isValid method of the object, which checks that the object's data field is valid, and finally that the object is in the currently active stage (universe).
boolean AlAreEqual(AlObject* o1, AlObject* o2);
This function should be called whenever it is necessary to check whether two OpenAlias pointers are referencing the same Alias object. Note that the two pointers may reference different OpenAlias wrappers, but those wrappers may both reference the same Alias object. Use this function instead of checking for pointer equality.
Note: if both pointers are NULL, FALSE will be returned.
const char *AlGetAliasPreference( const char *name );
This function gets the value of the Alias preference of the given name. An Alias preference is an assignment of a value to a name. These assignments are defined in the file $HOME/.AliasPrefs. They are settable through the preferences window in Alias, or by editing the file directly. This function is not available in OpenModel. This function will return the value of the preference, or NULL if the given name does not exist.
statusCode AlPromptBox(AlConfirmType type, char *msg, AlAnswerType* ans, short x, short y );
This function brings up a dialog box, prompting the user for confirmation. Two kinds of dialog boxes are supported: yes/no/cancel and ok/cancel. The width of the prompt box will be set by the longest line of the message. This function is not available in OpenModel.