domObj.getObjectsByType
(Merge only) (As of 3.1.002.06)
Find all objects in the current DOM which match a specified object type (or types). Find all objects that match an object type.
Syntax
domObj.getObjectsByType
(
type,
[,
type
...] [
callback])
Parameters
type is either a simple object type, or an array of object types to search for. The following is a list of DocOrigin object types:
Object type names: |
---|
"Form", "Page", "Container", "Pane", "Group", "Line", "Rectangle", "Table", "Row", "Cell" |
"Field-Text-String", "Field-Text-Number", "Field-Text-Currency", "Field-Text-DateTime", "Field-Text-Date", "Field-Text-Time" |
"Field-Checkbox", "Field-Radiobutton", "Field-Image", "Field-Barcode", "Field-Comb" |
"Label-Text", "Label-Image", "Label-Barcode" |
"Arc", "PolyLine" (dynamically generated by _chart ) |
callback is an optional JavaScript function that will be called for each successful match.
Returned Value
If a callback function is specified, this function returns TRUE. Otherwise, it returns a JavaScript array of pointers to DocOrigin DOM objects. That array is empty if no matches are found.
Background
This routine searches only the current object (typically the object containing this script) as well as all objects within this object. When using the callback function, you can cause the search of the DOM to terminate prematurely by having the callback function return TRUE. Otherwise, the callback is called for every match in the DOM. This can be useful (for example) if you're only interested in the first match, or already know that there is in fact only one object that will match. This might improve the program's speed.
Example
var p=getObjectsByType('Field-Barcode'); for(i=0; i<p.length; i++) { _logf("%d. name='%s' value='%s'", i, p[i]._name, p[i]._value); }
The above script will generate a listing of all Fields that are displayed as barcodes. If this script is put on a top-level object (Form, Page, Container,) then all instances are found. If it occurs on a lower-level Pane it will only find the instances within that Pane.
function myfun(p) { _logf("%d. name='%s' value='%s'", i, p._name, p._value); if (p._value == 0) return true; // quit when a value of zero is encountered } getObjectsByName('Field-Barcode', myfun);
This second example does the same thing as the first, but via a callback routine. It also terminates the search if an object with a value of zero is encountered.
See Also
domObj.getObjectsByTag
domObj.getObjectsByName