Nasal library/io: Difference between revisions

Jump to navigation Jump to search
→‎Functions: Start read_properties()
(→‎Functions: Start read_properties())
Line 209: Line 209:


=== read_properties() ===
=== read_properties() ===
Load XML file in FlightGear's native <PropertyList> format.        
{{Nasal doc
If the second, optional target parameter is set, then the properties  
|syntax = io.read_airport_properties(path[, target]);
are loaded to this node in the global property tree. Otherwise they
|text = Load XML file in FlightGear's native {{tag|PropertyList}} format. If the second, optional target parameter is set, then the properties are loaded to this node in the global property tree. Otherwise they are returned as a separate props.Node tree. Returns the data as a <code>props.Node</code> on success or nil on error.
are returned as a separate props.Node tree. Returns the data as a  
|param1 = path
props.Node on success or nil on error.
|param1text = Path to the XML file.
<syntaxhighlight lang="nasal">
|param2 = target
Usage:  io.read_properties(<filename> [, <props.Node or property-path>]);
|param2text = Optional place to put the results in the [[Property Tree]]. May be either a <code>props.Node</code> object or a property path.
</syntaxhighlight>
|example1 = var target = props.globals.getNode("/sim/model");
 
io.read_properties("/tmp/foo.xml", target);
Examples:
|example2 = var data = io.read_properties("/tmp/foo.xml", "/sim/model");
<syntaxhighlight lang="nasal">
var data = io.read_properties("/tmp/foo.xml");
var target = props.globals.getNode("/sim/model");          
}}
io.read_properties("/tmp/foo.xml", target);                
                                                           
var data = io.read_properties("/tmp/foo.xml", "/sim/model");
var data = io.read_properties("/tmp/foo.xml");            
</syntaxhighlight>


=== readfile() ===
=== readfile() ===

Navigation menu