Table of Contents

root.Document

Motivation

The reason why I wanted this method is to have an additional interface to access already loaded documents (from within scripts) without being given there handles. The method closely works together with the root.Documents method–please also read this page…

Method reference ('root.Help('Document')')

 ROOT::Document  - get one "Document" (VB-Style interface)
 
 FORMAT:       object = xff.Document(dspec);
 
 Input fields:
 
       dspec       either numbered object or (partial) filename
 
 Output fields:
 
       object      found object (otherwise: error)

Examples

If you already know that an object by the name SB5318_ISO_SAG.vmr is loaded, the following syntax gives you the object handle:

xff_root_document_ex1.m
% get root object handle
root = xff;
 
% access document
vmr = root.Document('SB5318_ISO_SAG.vmr');

Naturally, in scripts you would rather look this information up:

xff_root_document_ex2.m
% get root object handle
root = xff;
 
% get all documents
docs = root.Documents;
 
% iterate until found
colin_brain = [];
for dc = 1:numel(docs)
    if ischar(docs{dc}) && ...
       ~isempty(regexpi(docs{dc}, 'colin_brain'))
        colin_brain = root.Document(docs{dc});
        break;
    end
end
 
% load anyway
if isempty(colin_brain)
    colin_brain = neuroelf_file('c', 'colin_brain.vmr');
end