TOC PREV NEXT INDEX

Using AVS/Express



14 Properties, Attributes, Primitives, and Functions


This chapter provides reference information for the following AVS/Express components:

It contains the following sections:

14.1 Base Types

Base types-primitives and others-are the fundamental building blocks of AVS/Express.

Table N-1
Base type
Description
Primitives:
    boolean
    byte
    char
    double
    enum
    float
    int
    short
    string
    ptr
    prim
Hold raw system data.
Boolean integer (0 or 1 only).
One-byte integer object.
One-byte object that can hold a single character.
Double-precision floating point object.
Enumerated data type.
Single-precision floating point object.
Integer object.
Short integer object.
NULL-terminated character string object.
Pointer data object that points to a user data structure.
Object with unset data type (used for any one of the above).
group
Defines an object with subobjects.
For more information about group objects, see Groups on page 5-5.
library
flibrary
Creates a library of objects.
Creates a library of objects whose V-code definition is stored in a V file.
For more information about library objects, see Templates and Library Objects on page 5-11.
macro
application
Hold a combinations of modules, macros, and connections.
For more information about macro objects, see Macros on page 5-6.
module
Holds parameters and methods to implement objects that interface to C or C++ code.
For more information about module objects, see Modules on page 5-5.
method
omethod
cmethod
cxxmethod
Interface directly to a C function or C++ method.
For more information about method objects, see Methods on page 8-4.
link
mlink
Route connections, often into or out of a macro or application object.
For more information about link objects, see Defining Link Objects on page 6-33.

14.2 Properties and Attributes

A property is a name-value association placed on an object that defines a characteristic of that object; for example:

Property names are usually defined by the system (though you can create your own) and relate to a specific aspect of object behavior. In V code, properties appear after the object name, delimited by the less-than (<) and greater-than (>) characters.

An attribute is a Boolean characteristic that you can apply to an object to modify its behavior. AVS/Express defines a fixed set of these characteristics.

A simple way to access many of the properties and attributes of an AVS/Express object is through the Properties Editor in the Network Editor. The Properties Editor provides a Property Group options menu from which you can open a Properties Editor page containing either all or a subset of the properties and attributes accessible in the Network Editor. Note that not all properties and attributes are accessible in the Network Editor; some are accessible only when you are working in the object's V file.

For information on accessing properties and attributes in V, see Using the Properties Editor on page 5-47 and Chapter 7, V and the V Command Processor.

Properties and attributes can be classified as:

The following sections describe the members of these groups.

General Properties and Attributes

This table describes miscellaneous properties and attributes.

Table N-1
Name
Type and default
Description
dictionary
string
Default: "dictionary_name"
The name of a dictionary file to be loaded into a translation table for localization. The OM loads the dictionary from a file with the following relative pathname:
    runtime/nls/<locale_name>/<dictionary_name>
dimensions
boolean
Default: 1
If set, declares an object as an array and sets the dimensions of that array.
disabled
boolean
Default: 0
If set (to 1) on any hierarchical object, neither that object nor any of its children are not included in any compile operation. (A hierarchical object is a library, macro, group, or module.)
instanced
boolean
Default: 0 or 1, depending on the object's state
Changes the instanced state of an object:
-- If set to 0 on an instanced object, that object and all     of its subobjects are deinstanced (all deinstanced     methods are called).
-- If set to 1 on a deinstanced object, that object and all     of its subobjects are instanced (all instance  functions     are called).
libfile
string
Default: "my_file.v"
The .v file to associate with an flibrary object. If the specified file name does not include a .v suffix, AVS/Express adds one and generates a binary .vo file to make subsequent loads of the flibrary faster.
libimm
integer
Default: 0
Can be used with the libfile property or with the file library syntax:
"foo.v" FOO;
It indicates that the library is to be loaded immediately when it is encountered, rather than waiting for some reference to objects in the library to force it to be loaded. You need this property when you define any objects with virtual data.
locked
integer
Default: 0
If set to 1, the object's subobjects cannot be added or removed.
need_virtual
string
Default: "virt_name1 virt_name2"
Defines a dependency between an object or library and one or more pieces of virtual data. When this object or library is needed for a project, all objects that define virtual data are also added to this project.
nosave
attribute
Default: none (unset)
If set, the object is not saved with the rest of the application state.
nres
attribute
Default: none (unset)
If set, warnings normally generated if the object is not immediately resolvable are suppressed.
rdonly
boolean
Default: 0
If set, makes connections to an object read only.
ref_mode
string
Default: depends on object (usually "^")
Allowed values:
"*"
"&"
"^"
The object's reference mode; that is, whether it is a pointer ("*"), a reference ("&"), or an actual value object ("^"). Reference mode is an intrinsic property of an object, so you should treat ref_mode as read only and not use it to set a value.
trace
attribute
Default: none (unset)
Performs a trace on the object.
ui_default_shell
boolean
Default: 1
If set to 0 on a DefaultApplication object, prevents UImod_panel objects instantiated in the application or its children from creating and displaying their own shells.
user_class
integer
Default: 0
If set to 1 for an object in a library on which user_library is set to 0, forces the object to be derived from when copies are made.
user_library
integer
Default: 1
If set to 0 on a library, indicates that the objects in this library cannot not be derived from.
user_name
string
Default: "obj_name"
An alternate name for the object to display in the Network Editor.
val_state
integer
Default: 1
Sets an explicit value state for the object for save and restore operations.
virtual
attribute
Default: none (unset)
If set, specifies that the object is virtual.

Network Editor Properties

This table describes Network Editor properties, which affect the object's appearance in the Network Editor.

Table N-2
Name
Type and default
Description
NEbackgroundPixmap
filename
Default: "graph.x"
The name of an AVS image file that contains the definition of a pixmap to be displayed in the background of the subwindow of an open macro object.
You can specify an absolute or a relative pathname. If you specify a relative pathname, AVs/Express searches for the file in the following directories:
-- The directory specified by the     XP_PIXMAP_PATH environment     variable (if set)
-- The runtime/pixmaps subdirectory of each     component of the XP_PATH variable,     defined in either the environment or your     avsenv file
-- The current directory
NEcolor0
NEcolor1
NEcolor2
NEcolor3
NEcolor4
NEcolor5
integer
Default: 0x303030
The value of the ith color of an object's port. Specify the value as a hexadecimal number of the form 0xrrggbb, where rr, gg, and bb are the RGB components of the color; for example:
    yellow = 0xffff00
The number of colors is specified using the NEnumColors property. Each color occupies an equal portion of the port.
NEdisplayMode
string
Default: "closed"
Allowed values:
"closed"
"open"
"maximized"
A value indicating whether the object is closed, open, or maximized. Display mode is normally controlled by popup commands, hence this property does not appear in the Properties Editor. However, it is included in an object's V definition when you save it to a file.
NEeditable
boolean
Default: 1
A flag indicating whether the following is allowed:
--Adding subobjects to or deleting them from     the object
-- Editing characteristics of the subobjects
-- Destroying the subobject
NEgridHeight
NEgridWidth
float
Default: 11.0
The size (in pixels) of the grid to which all subobjects of a macro are snapped when positioning them.
NEheight
float
Default: dynamic
The height (in pixels) of an open object when displayed inside an open macro object.
NEhelpContextID
integer
Default: none (unset)
The HyperHelp context ID associated with the the object's online help.
This property is provided for developers who have obtained a license from Bristol Technologies Inc. for developing their own online help.
NEhelpFile
filename
Default: "express.hlp"
The name of the HyperHelp .hlp file that contains the object's online help.
You can specify an absolute or relative pathname. If you specify a relative pathname, AVS/Express searches for the file in the runtime subdirectory of each component of the XP_PATH variable, defined in either the environment or your avsenv file.
This property is provided for developers who
have obtained a license from Bristol Technologies Inc. for developing their own online help.
NEhelpTopic
string
Default: none (unset)
The HyperHelp topic associated with the object's online help.
This property is provided for developers who have obtained a license from Bristol Technologies Inc. for developing their own online help.
NEiconDisplayMode
string
Default: "pixmap_and_text"
Allowed values:
"pixmap"
"text"
"pixmap_and_text"
A value that indicates whether a pixmap, text, or both are displayed in an object's icon.
NElargePixmapName
filename
Default: none (unset)
The name of the file that contains the pixmap that is displayed when the value of the NEpixmapMode property is "large".
You can specify an absolute or a relative pathname. If you specify a relative pathname, AVs/Express searches for the file in the following directories:
-- The directory specified by the     XP_PIXMAP_PATH environment     variable (if set)
-- The runtime/pixmaps subdirectory of each     component of the XP_PATH variable,     defined in either the environment or your     avsenv file
-- The current directory
NElargePixmapType
string
Default: "bmx"
Allowed values:
"avs_image"
"x_bitmap"
"bmx"
The format of the file containing the pixmap that is displayed when the value of the NEpixmapMode property is "large". The allowed values indicate the following file formats:
-- "avs_image" is an AVS image format.
-- "x_bitmap" is the standard monochrome     X bitmap format.
-- "bmx" is BMX format, an AVS/Express     format derived from the Windows BMP     format.
NEnumColors
integer
Default: 1
The number of colors used when drawing the object's port. The maximum is 6. To specify individual colors, use the properties NEcolor0 through NEcolor5.
NEopenable
boolean
Default: 1
A flag that indicates whether the object can be opened in the Network Editor. Use this property to prevent users from viewing and modifying certain components.
This property does not appear in the Properties Editor.
NEpixmapMode
string
Default: "small"
Allowed values:
"small"
"large"
A value indicating the layout of the pixmap and text in the object icon.
-- If the value is "small", the pixmap is     displayed at the left side of the icon and the     text is displayed to the right of the pixmap.
-- If the value is "large", the pixmap is displayed    above the text and both the pixmap and the     text are horizontally centered.
Note that "small" pixmap mode is always used when an object is open.
NEpopupMenu
string
Default: "Templates.
NE_MACROS.
NEobjPopupMenu"
The pathname of the temporary object that is used for displaying the popup menu for an object. The default version of the popup menu is defined in ne_macro.v and the components of the menu are defined in ne.v. To customize the popup menu for your objects, specify the pathname of your own popup menu.
NEportLevels
two integers
Default: {0,0}
The extent to which the input and output ports of an object are exposed. The first integer controls the input port, and the second controls the output port. Port level values have the following meanings
-- 0: The port is not exposed.
-- 1: The object is exposed to the level of the     object's siblings.
-- 2: The object is exposed to the level of both     the object's siblings and the siblings of the     object's parent.
-- Greater than 2: The object is exposed further.
NEscalingFactor
float
Default: 1.0
The scaling (zoom) factor for objects in the subwindow of an open macro object. Zooming is normally controlled by the mouse or popup menu, hence this property does not appear in the Properties Editor . However, it is included in an object's V definition when you save it to a file.
NEsmallPixmapName
filename
Default: none (unset)
The name of the file containing the pixmap displayed when the value of the NEpixmapMode property is "small".
You can specify an absolute or a relative pathname. If you specify a relative pathname, AVs/Express searches for the file in the following directories:
-- The directory specified by the     XP_PIXMAP_PATH environment     variable (if set)
-- The runtime/pixmaps subdirectory of each     component of the XP_PATH variable,     defined in either the environment or your     avsenv file
-- The current directory
NEsmallPixmapType
string
Default: "bmx"
Allowed values:
"avs_image"
"x_bitmap"
"bmx"
The format of the file containing the pixmap that is displayed when the value of the NEpixmapMode property is "small". The allowed values indicate the following file formats:
-- "avs_image" is an AVS image format.
-- "x_bitmap" is the standard monochrome     X bitmap format.
-- "bmx" is BMX format, an AVS/Express     format derived from the Windows BMP     format.
NEupstream
boolean
Default: 0
A flag that prevents AVS/Express from considering the object's port when it executes the Arrange Icons popup command for an open macro object.
NEvisible
boolean
Default: 1
A flag indicating whether an object is displayed in the Network Editor. Use this property to hide objects from end users.
NEwidth
float
Default: dynamic
The width (in pixels) of an open object when displayed inside an open macro object.
NEx
NEy
float
Default: 0.0
The X and Y position (in pixels) of an object when displayed inside an open macro object.
NExOffset
NEyOffset
float
Default: 0.0
The X and Y panning offset (in pixels) of all children of a macro object. Panning is normally controlled by the mouse, hence this property does not appear in the Properties Editor. However, it is included in an object's V definition when you save it to a file.

Module-Control Properties and Attributes

This table describes module-control properties and attributes, which specify the information necessary to determine the behavior of a module's methods and parameters.

For more details, see Chapter 8, Developing Modules.

Table N-3
Name
Type and default
Description
no_meth_ctx
int
Default: 1
If set to 1, enables the following behavior: if an object with an update method is instanced, and a new subobject is added whose "notify" attribute is set, the update method fire in responses to a change in the value of the new subobject.
noevents
attribute
Default: none (unset)
If set on a parameter, specifies that the module does not affect that parameter or its subobjects in any way. Setting this property is equivalent to setting nonotify+noread+nowrite on a parameter.
nonotify
attribute
Default: none (unset)
If set, forces the notify attribute off even if the inherited value is on.
noread
attribute
Default: none (unset)
If set, forces the read attribute off, even if the inherited value is on.
notify
attribute
Default: none (unset)
Specifies that all of an object's methods are invoked when the value of the subobject on which this attribute is set changes.
notify_inst
attribute
Default: none (unset)
If set for a method subobject, specifies that method is invoked when the object is instantiated
notify_deinst
attribute
Default: none (unset)
If set for a method subobject, specifies that method is invoked when the object is destroyed
nowrite
attribute
Default: none (unset)
If set, forces the write attribute off, even if the inherited value is on.
opt
attribute
Default: none (unset)
Helps to determine the conditions for invoking an update method. Also, specifies that the object is optional for the purposes of object matching
read
attribute
Default: none (unset)
If set on the subobject of a module, causes AVS/Express to generate code that makes it easier to get the value of that subobject inside a method. For C, it will generates the code to get the method; for OMX, it will generate a comment that notes that the variable is exported and available
req
attribute
Default: none (unset)
If set on the subobject of a module, tells AVS/Express not to fire any method that reads this subobject unless it has a defined value
weight
int
Default: 1
If set, specifies the order in which a set of methods all responding to the same event are called. If unset, the order is undefined.
write
int
Default: 0
If set on the a subobject of a module, tells AVS/Express to export that subobject for writing; that is, generate code in methods of the module to make it easier to set the value of this subobject.

Code Management Properties

This table describes code management properties, which are used when compiling projects. These properties generally apply only to modules and libraries, and therefore appear in the Properties Editor only for these objects.

For more details, see Providing Code Management Information on page 8-28.

Table N-4
Name
Type and default
Description
build_cmd
string
Default: none (unset)
A make command to execute. The command is performed in the build directory (see build_dir, elsewhere in this table). For example:
build_cmd="$(MAKE)"
build_dir
string
Default: "."
The name of the build directory. You can specify an absolute pathname or a pathname relative to XP_PATH (see The XP_PATH Environment Variable on page 10-24). For example:
build_dir="gd"
c_hdr_files
string
Default: "my_hdr1.h
my_hdr2.h"
C header files that AVS/Express includes in the code it generates as part of encapsulating a structure or function. The specified header files must be in the header directories (see hdr_dirs, elsewhere in this table).
c_src_files
string
Default: "src1.c
src2.c"
A list of C source files to be compiled. You can specify an absolute pathname or a pathname relative to the build directory (see build_dir, elsewhere in this table). For example:
c_src_files="src1.c src2.c"
See also src_file, elsewhere in this table.
compile_subs
boolean
Default: 1
If set to 0, specifies that the object and objects below it in the object hierarchy are never compiled.
You use this property for efficiency. For example, a macro object typically consists of objects defined elsewhere, so does not itself need to be compiled. If you have a large library of such objects, you can spare AVS/Express the effort of searching the library. You typically insert this property into the library:
compile_subs=0
cxx_hdr_files
string
Default: "my_hdr1.hxx
my_hdr2.hxx"
C++ header files that AVS/Express includes in the code it generates as part of encapsulating a structure or function. These header files must be in the header directories (see hdr_dirs, elsewhere in this table).
cxx_src_files
string
Default: "src1.cxx
src2.cxx"
A list of C++ source files to be compiled. You can specify an absolute pathname or a pathname relative to the build directory (see build_dir, elsewhere in this table). The default make rules can compile only C++ source files that have the .cxx suffix. For example:
cxx_src_files="src1.cxx src2.cxx"
hdr_code
string
(none)
The declaration of a function called in the line of C code specified by the init_code property (elsewhere in this table). For example:
hdr_code="int FLD_METHinit();"
init_code=FLD_METHinit();"
hdr_dirs
string
Default: "include ."
A list of directories to search for header files (equivalent to a compiler's -I option). You can specify an absolute pathname or a pathname relative to the build directory (see build_dir, elsewhere in this table).
init_code
string
Default: none (unset)
A line of C code to execute when the process starts. If the C code calls a function that is not declared, use the hdr_code property (elsewhere in this table) to declare the function. For example:
hdr_code="int FLD_METHinit();"
init_code=FLD_METHinit();"
lang
string
Default: "cxx"
The language of a method's function, either C or C++. The default language is C, so you need to specify this property only when the language is C++. Unlike the other process properties, lang is not inherited. You need to specify this property only when the OM cannot determine the language itself, for example, when a C module calls a C++ function.
Note that you use the string "cxx" rather than "c++".
libdeps
string
Default: none (unset)
The names of other AVS/Express libraries that must be included in each process in which this object is placed. You can use this property to specify dependencies in code that are not expressed in the dependencies between the AVS/Express objects themselves. Any link files associated with the specified libraries are included in any process in which this object is used. For example:
libdeps = "GDIF REN UI"
link_files
string
Default: "-lmy_lib1 libmy_lib2.a my_obj1.o my_obj2.o"
Text to pass to the linker (without interpretation, in the linker line), typically object (.o) files and object libraries. This property is useful for specifying library paths, libraries, and/or object files to link in, and so on. Use it instead of (or in addition to) the c_src_files and cxx_src_files properties (elsewhere in this table) when you use your own make file compile your source. For example:
link_files="-L /my_lib_dir -lmods -lmutil"
need_cxx
boolean
Default: 0
If set to 1, specifies that the C++ linker is required for this process. AVS/Express can generally determine whether the C++ linker is required by observing whether any method object specifies lang="cxx" or has a cxxmethod subobject.You use this property when it cannot determine this. For example, if a method calls a C function and that function in turn calls a C++ function, AVS/Express does not know about the C++ function and therefore not know that the C++ linker is required.
need_objs
string
Default: none (unset)
The path names of other AVS/Express objects created dynamically by this module. You use this property to ensure that these objects are included in a compiled project that contains your modules. For example:
need_objs = "UIbutton MODS.clamp"
no_main
boolean
Default: 0
If set to 1 on any object included in a process, AVS/Express does not link a "main()" function into the process. In this case, you must supply your own "main()" function using a cxx_src_file, c_src_file, or link_files property (described elsewhere in this table).
out_hdr_file
string
Default: express.h
The name of a header file that contains automatically generated header definitions for this object and its subobjects. Do not edit this header file; it is maintained by AVS/Express relative to the current build directory (build_dir, elsewhere in this table). This header file includes the declaration of any methods and definitions for OMX and UCI objects. If you do not specify a value for this property for an object or its ancestor, definitions are placed in processname.h. For example:
out_hdr_file="uci_gmod.h"
out_src_file
string
Default: express
The name of a source file that contains automatically generated source code for this object and its subobjects. Do not edit this source file; it is maintained by AVS/Express relative to the current build directory (build_dir, elsewhere in this table). This source file includes code to support OMX and UCI objects. Specify the file name without a suffix so that the system can append a .c or .cxx suffix depending upon whether it includes C++ definitions. If you do not specify a value for this property for an object or its ancestor, definitions are placed in processname.[c|cxx]. For example:
out_src_file="uci_gmod"
pre_init_code
string
Default: ""
A line of C code to execute before templates are loaded. If the C code calls a function that is not declared, use the hdr_code property to declare it.
process
string
Default: express
The process to which the object belongs. For example:
process="user"
For more details about using the process property, see Defining Processes for Objects on page 10-12.
For details on creating a new process (that is, a process other than the existing express and user processes), see Creating New Processes on page 10-14.
src_file
string
Default: none (unset)
A file into which to generate prototype source code for the object. If the generated code is C, any existing source code is not overwritten and must be explicitly deleted each time new code is to be generated. If it is C++, the existing source code is not changed, but any methods to be generated that are not already defined in the existing code are added to the end. This property is also used in conjunction with the Project->Edit Source pull-down command. For example:
src_file="myfunc.c"
use_src_file
boolean
Default: 1
If set to 0, disables the generation of prototype source for an object and its subobjects. For C++ only, use this property if you do not want AVS/Express to maintain the correspondence between the source file (src_file, elsewhere in this table) and the methods in these objects.

C++ Interface Properties

This table describes C++ interface properties, which are used by objects with C++ methods (cxxmethod subobject). These properties control the interface between objects and C++ code.

For details, see C API Usage Notes on page 9-16.

Table N-5
Name
Type and default
Description
cxx_abstract
boolean
Default: "0"
If set, prevents AVS/Express from generating a constructor call for an abstract class.
cxx_class
string
Default: "my_class"
The name of a C++ class with which to associate the object. When the object is instanced, an instance of the class is created; when the object is deinstanced, the class instance is also deinstanced. When a cxxmethod subobject is called, a pointer to the C++ class instance can be obtained. Set the cxx_hdr_files and cxx_src_files properties to include the source files that define the C++ class to be thus imported.
See also cxx_class_args, cxx_abstract, cxx_src_files, and cxx_hdr_files, elsewhere in this table.
cxx_class_args
string
Default: "arg1,arg2,arg3"
Used in conjunction with the cxx_class property to specify the parameters (if any) to the constructor for an imported C++ class. Place the specified string between the parentheses in the generated call to the class's constructor.
cxx_hdr_files
string
Default: "my_hdr1.hxx my_hdr2.hxx"
C++ header files that AVS/Express includes in the code it generates as part of encapsulating a structure or function. The header files specified must be in the header directories (see hdr_dirs, in the table in Code Management Properties on page 14-13).
cxx_members
string
Default: "int v1, v2;"
Defines additional members in an exported C++ class. For example:
cxx_members="char *my_ptr;"
The text string is inserted directly into the class definition, so it must have correct C++ syntax. Note that you can make the member private:
cxx_members="private: char *my_ptr;"
Normally, the only class members are the exported objects in the object hierarchy.
See cxx_members_constr, elsewhere in this table.
cxx_members_constr
string
Default: "v1(1),v2(2)"
Code with which to construct new C++ class members added using the cxx_members property. The specified string is added to a comma-separated list after the class constructor. For example:
cxx_members_constr="my_ptr(0)"
See cxx_members, elsewhere in this table.
cxx_name
string
Default: none (unset)
A name to use for the object in generated C++ code.
cxx_src_files
string
Default: "src1.cxx src2.cxx"
A list of C++ source files to be compiled. You can specify an absolute pathname or a pathname relative to the build directory (see build_dir, in the table in Code Management Properties on page 14-13). The default make rules can compile only C++ source files with the .cxx suffix. For example:
cxx_src_files="src1.cxx src2.cxx"
export
int
Default: 0
Specifies how many levels up the object hierarchy to export an object. For example:
-- A value of 0 means that the object should not be     exported.
-- A value of 1 exports the subobject to its parent.
-- A value of 2 exports the subobject to its parent's    parent.
This is useful for fine-tuning the exporting of individual subobjects in an exported object hierarchy.
See export_cxx, elsewhere in this table.
export_cxx
int
Default: 1
Controls how Express generates C++ code for an object. The allowed values are as follows:
-- 0: Do not generate a C++ class for this object.
-- 1: Generate a C++ member for each     AVS/Express subobject unless its export     property is set to 0. This is the default for any     module with a cxxmethod subobject.
-- 2: Generate a C++ member only for      AVS/Express subobjects whose NEportLevels     or export property is set to 2 or higher; that is,     they export themselves at least to their parent     object.
-- 3: Generate a C++ member for each subobject
     whose NEportLevels or export property is set     to export itself to the current object's level.
See export, elsewhere in this table.
export_all
int
Default: 0
If set, specifies that by default, all subobjects are exported.
export_subs
int
Default: 0
If set, specifies that subobjects are exported.

14.3 Defining Combinations of Properties and Attributes

Some objects in AVS/Express are defined solely to manage common combinations of properties and attributes so that V language definitions of objects can utilize a short-hand representation for referring to this group of attributes. In order to understand how these objects work, it is important to understand the general concepts behind the merge operation.

The Merge Operation

The merge operation that applies to groups, modules, and macros applies to other objects as well but it behaves somewhat differently.

In general, you can merge the definition of any template object into a compatible destination object. All information in the template object is added to the destination including properties, attributes, dimensions, data type, subobjects and value. When the destination object already has a conflicting definition of a particular piece of information, it is replaced by the new definition from the template object.

The objects involved in the merge operation must be compatible base types. You cannot merge a primitive data object into a group for example. If the objects involved in the operation are groups, modules, or macros, the template object is added to the derivation hierarchy of the destination object. If the object is not a group, module, or macro, the merge operation represents a one-time exchange of information. Future changes to the template are not propagated to the destination object as will happen with groups, modules, and macros.

Maintaining Properties and Attributes

The atts base type maintains properties and attributes. It can be merged into all different types of objects. When it is merged into a destination object, it simply copies the properties and attributes defined on it into the destination object. If the first type in a V construct is an attribute (such as the "read" attribute), the atts base type is implied. The following represent some standard AVS/Express V definitions of atts objects:

atts Port<NEportLevels=1>;
atts IPort<NEportLevels={1,0}>;
atts OPort<NEportLevels={0,2}>;
read+req+IPort2 Iparam; // here "atts" is implied.

These objects can be used when defining V descriptions of modules as short-hand for setting the NEportLevels property and the read, req attributes. You use these atts objects particularly when you are defining objects in V.

For example:

int+IPort foo;
Field+Iparam bar;

AVS/Express defines a collection of these atts objects that you can use:

atts object name
Definitions
Port
sets NEportLevels = 1
IPort
sets NEportLevels = {1,0}
OPort
sets NEportLevels = {0,1}
Port2
sets NEportLevels = 2
IPort2
sets NEportLevels = {2,0}
OPort2
sets NEportLevels = {0,2}
Port3
sets NEportLevels=3
IPort3
sets NEportLevels={3,0}
OPort3
sets NEportLevels={0,3}
Iparam
sets NEportLevels={2,0}, read, req
Oparam
sets NEportLevels={0,2}, write, nonotify

14.4 Built-in Functions

AVS/Express supplies a large number of built-in functions. These functions can be classified as follows: mathematical, logical, array, and miscellaneous- index_of, merge, name_of, str_array, and str_format, and switch. A value expression can contain built-in functions.

For more information on these functions as expressed in V, see V Functions on page 7-46

Mathematical Functions

The following table summarizes the AVS/Express mathematical functions.

Table N-1
Mathematical function
Description
abs(arg)
Absolute value of arg.
acos(arg1...)
Arc cosine of arg, expressed in radians.
add(arg1...)
Addition; equivalent to arg1 + arg2 + ... .
asin(arg)
Arc sine of arg, expressed in radians.
atan(arg)
Arc tan of arg, expressed in radians.
cos(arg)
Cosine of arg, expressed in radians.
cosh(arg)
Hyperbolic cosine of arg, expressed in radians.
divide(arg1...)
Division; equivalent to arg1 / arg2 / ... .
exp(arg)
e raised to the power of arg.
log(arg)
Natural logarithm of arg.
log10(arg)
Base 10 logarithm of arg.
modulo(arg1...)
Modulo; equivalent to arg1 % arg2 % ... .
multiply(arg1...)
Multiplication; equivalent to arg1 * arg2 * ... .
pow(arg1, arg2)
arg1 raised to the power of arg2.
sin(arg)
Sine of arg, expressed in radians.
sinh(arg)
Hyperbolic sine of arg, expressed in radians.
sqrt(arg)
Square root of arg.
sub(arg1...)
Subtraction; equivalent to arg1 - arg2 - ... .
tan(arg)
Tan of arg, expressed in radians.
tanh(arg)
Hyperbolic tan of arg, expressed in radians.
rand(range, [ seed ])
A random scalar or array with values from 0 to range. The seed value is used as the seed for the random numbers. If no seed argument is specified, the object ID is used as the seed, and a different random array is returned for each object.

Logical Functions

The following table summarizes the AVS/Express logical functions..

Table N-2
Logical function
Description
and(arg1...)
Logical and; equivalent to arg1 & arg2 & ...
or(arg1...)
Logical or; equivalent to arg1 | arg2 | ...
xor(arg1...)
Logical exclusive or; equivalent to ((arg1 ^ arg2) ^ ...)

Array Functions

The following table summarizes the AVS/Express array functions.

Table N-3
Array function
Description
array_size(arg)
Returns the total number of elements in arg.
array_dims(arg)
Returns the dimensions of the array specified in arg.
combine_array(arg1...)
Combines the arrays arg1, arg2, ... The arrays must have the same number of dimensions (n) and the same size in the first n-1 dimensions. The function returns an n-dimension array, whose size in the first n-1 dimensions is the same as that of the source arrays, and the size of whose nth dimension is the sum of the sizes of the source arrays' nth dimensions.
concat_array(arg1, ...)
Concatenates arg1, arg2, ... to create a single array with dimensions equal to the sum of dimensions of all the arrays.
index_of(arg)
Returns the index of the current object in the array of groups specified by arg. This function must be used by an object that is in a group in the array of groups specified by arg. It is used to create connections between objects in two parallel arrays of groups.
init_array(size,start,end)
Returns a one-dimensional array of size elements that range in ascending order from start to end.
magnitude(arg)
Returns the magnitude (square root of the sum of squares) of each column in arg. The function returns an n-1 dimension array, where n is the number of dimensions in arg.
max_array(arg)
max_array(arg, f, v)
Returns in a one-dimensional array the maximum value found in each column in the array arg.

If the array has null values, you can include two additional arguments:
-- Set the flag f to 1 to indicate that the function should ignore null     values.
-- Set v to the number that represents a null value.
By default, f is 0, meaning that the function operates on all array values.
min_array(arg)
min_array(arg, f, v)
Returns in a one-dimensional array the minimum value found in each column in the array arg.

If the array has null values, you can include two additional arguments:
-- Set the flag f to 1 to indicate that the function should ignore null     values.
-- Set v to the number that represents a null value.
By default, f is 0, meaning that the function operates on all array values.
prod(arg1...)
Returns the product of all of the elements in arg1, arg2, ... .
sum(arg1...)
Returns the sum of all of the elements in arg1, arg2, ... .
sum_array(arg1)
Creates a new array, each element of which is a sum of all the previous elements in the original array.

Note the following:

Examples
-> int x = 10;
-> int y = 20;
-> int z = 3;
-> int a = max_array ({x, y, z});
-> $int a
20
-> float x[2][3] = {{1,2,3},{4,5,6}};
-> float y[2][2] = {{7,8},{9,10}};
-> int a => array_size(x);
-> $int a
6
-> float a[] => combine_array(x,y);
-> $get_array a
{{1,2,3,7,8},{4,5,6,9,10}}
-> $array_dims a
ndim=2 [2][5]
-> int a1[3]={1,2,3};
-> int a2[3]={5,6,7};
-> int a3[3]={8,9,10};
-> int c[] => concat_array(a1,a2,a3);
-> $get_array c
{1,2,3,5,6,7,8,9,10}
-> float a[] => magnitude(x);
-> $get_array a
{3.74166,8.77496}
-> float a => max_array(x);
-> $real a
6.000000
-> float a => prod(x,y)
-> $real a
3628800.000000
int a[4]={1,2,3,4};
int b[] => sum_array(a);
$get_array b
{1,3,6,10}
Miscellaneous Functions

The following table summarizes miscellaneous AVS/Express functions.

Table N-4
Function
Description
cache
Instructs AVS/Express to cache the results of the enclosed expression so that the expression is recalculated only when necessary
index_of
Returns the current index of an array of groups
merge
Defines an object with all the subobjects of two or more other objects
name_of
Returns a string value that contains the name of a referenced object
str_array
Returns an array of strings obtained by splitting a referenced string object into pieces
str_format
Provides string formatting functionality like that of the standard C routine printf
switch(index,arg1,arg2...)
Returns the argument indicated by the index argument; for example, returns arg4 if index is 4

cache Function
cache (expression)

The cache function instructs AVS/Express to cache the result of the enclosed expression, so that the expression is recalculated only if the objects referenced in the expression have changed.

When an object is connected to an expression, AVS/Express by default recomputes an expression whenever the object's value is requested.

Caching involves a trade-off between the time required to recalculate an expression and the space required to cache the result.

For example, you define a group whose method creates a large array of float data, stored in subobject out. You also define an object called max and connect it to the maximum value in out:

group create_data {
float+write out[];
method_upd func = "create_data";
};
float max => max_array(out);

By default, every time you request max's value, AVS/Express recalculates the expression, even if out has not changed. To prevent this, use the cache function:

float max => cache(max_array(out));

The cache function caches the result of an expression so that it is recomputed only when objects referenced by the expression have changed.

index_of Function
index_of (group_array_object)

The index_of function returns the current index of an array of groups. You can use index_of in the value expression for a subobject of the array of groups.

For example:

group foo[3] {
int a=> index_of(foo);
};
!foo[0] {
$int a
0
};
!foo[1] {
$int a
1
};
merge Function
merge (object1, object2, ...)

The merge function defines an object that has all of the subobjects of object1 combined with the subobjects of object2.... etc. This is not a static merge like the "+" operator but continues to get changes made to its object arguments.

If subobjects of the same name exist in more than one object argument, the merge object uses the subobject found in the first object in the argument list.

For example:

-> group a {
-> int sub1 = 10, sub2 = 20;
-> };
-> group b {
-> int sub2 = 30, sub3 = 40;
-> };
-> group &c => merge(a,b);
-> c {
-> $print sub1
int sub1 = 10;
-> $print sub2
int sub2 = 20;
-> $print sub3
int sub3 = 40
name_of Function
name_of(object)

The name_of function returns a string value containing the name of the object object. For example:

-> group grp1 {
-> string str1 => name_of(<-);
-> $str str1
grp1
str_array Function
str_array(string_object, delimiter)

The str_array function returns an array of strings that are obtained by splitting up string_object into pieces delimited by the first character of the string value of the delimiter argument.

For example:

-> string a = "One;Two;Three";
-> string b[3] = str_array(a, ";");
-> $print b
string b[3] = {"One","Two","Three"};
str_format Function
str_format(format, arg1, arg2, ..., argn)

The str_format function provides string formatting functionality like the standard C routine printf. The format parameter is a string defined just like the format parameter to printf. The format parameter contains two types of objects: characters that are placed directly in the string's value, and conversion specifications of the form:

%[field width].[precision][conversion character]

The nth argument after format corresponds to the nth conversion specification in the format string. The data type of the argument is determined by the data type required by the conversion character.

Data type
Conversion characters
integer
d, i, o, u, x, X
real
e, E, f, g, G
string
s
pointer
p

If any one of the arguments after format is an array, this function provides an array of strings where the format string is applied to each value in the array individually. Otherwise, this function returns a scalar string value.

This function does not interpret the %n$ syntax of the printf function.

Example

For example:

-> string v1 => str_format("number: %5d %s",3,"foobar");
-> $str v1
number: 3 foobar
-> string arr1[] => str_format("%10.3f",{1.2345,2.34,4.56});
-> string arr2[3] = arr1;
-> $print arr2
string arr2[3] = {" 1.234"," 2.340"," 4.560"};
switch Function
switch(index,arg1,arg2...)

The switch function returns one of its arguments depending on the value of index. If index is 1, switch returns the first argument. If index is 2, switch returns the second argument, and so on. If index is 0 or greater than the total number of arguments, a null value is returned.

When used as a primitive, switch's first subobject specifies the index; subsequent subobjects specify the arguments. For illustration of such usage, see the following example.

//
// Use switch as a primitive.
// Start by defining an index variable.
//
int i;

//
// Define a switch.
//
switch x {
int index => i;
int val1 = 10;
int val2 = 20;
};

// Define an integer and connect it to switch x.
//
int result => x;


TOC PREV NEXT INDEX