User Tools

Site Tools


root.document

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

root.document [2010/07/06 06:48] (current)
jochen created
Line 1: Line 1:
 +====== 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'​)'​) =====
 +<​file>​ 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)</​file>​
 +
 +===== 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:
 +
 +<code matlab xff_root_document_ex1.m>​% get root object handle
 +root = xff;
 +
 +% access document
 +vmr = root.Document('​SB5318_ISO_SAG.vmr'​);</​code>​
 +
 +Naturally, in scripts you would rather look this information up:
 +
 +<code matlab 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</​code>​
root.document.txt ยท Last modified: 2010/07/06 06:48 by jochen