Nasal library/io: Difference between revisions

→‎Functions: Start read_airport_properties()
(→‎Functions: Doc read())
(→‎Functions: Start read_airport_properties())
Line 189: Line 189:


=== read_airport_properties() ===
=== read_airport_properties() ===
Load XML file in FlightGear's native <PropertyList> format.        
{{Nasal doc
File will be located in the airport-scenery directories according to
|syntax = io.read_airport_properties(icao, fname[, target]);
ICAO and filename, i,e in Airports/I/C/A/ICAO.filename.xml          
|text = Loads an airport-related XML file in FlightGear's [[PropertyList]] format. Paths will be concatenated in the following form: <tt>''[[$FG_SCENERY]]/Airports/'''''i'''''/'''''c'''''/'''''a'''''/'''''icao'''''.'''''fname'''''.xml''</tt>. Returns the data as a <code>props.Node</code> object or <code>'''nil'''</code> on error.
 
|param1 = icao
If the second, optional target parameter is set, then the properties are loaded to this node in the global property tree.
|param1text = ICAO code of the airport.
Otherwise they are returned as a separate props.Node tree.  
|param2 = fname
Returns the data as a props.Node on success or nil on error.
|param2text = Filename of the airport data file, e.g., "groundnet"see above for its use in the concatenation of the path.
<syntaxhighlight lang="nasal">
|param3 = target
Usage:  io.read_properties(<filename> [, <props.Node or property-path>]);
|param3text =
</syntaxhighlight>
|example1 = var data = io.read_airport_properties("KSFO", "rwyuse");
 
}}
Example:
<syntaxhighlight lang="nasal">
var data = io.read_airport_properties("KSFO", "rwyuse");
</syntaxhighlight>


=== read_properties() ===
=== read_properties() ===