Line 193: |
Line 193: |
| |text = Loads an airport-related XML file. 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. Note that the file ''must'' be in the [[PropertyList XML files|PropertyList]] format, or else the function will fail. | | |text = Loads an airport-related XML file. 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. Note that the file ''must'' be in the [[PropertyList XML files|PropertyList]] format, or else the function will fail. |
| |param1 = icao | | |param1 = icao |
− | |param1text = ICAO code of the airport. | + | |param1text = ICAO code of the airport as a string. |
| |param2 = fname | | |param2 = fname |
− | |param2text = Filename of the airport data file, e.g., "groundnet", "ils", "jetways", "rwyuse", "threshold", or "twr". See above for its use in the concatenation of the path. | + | |param2text = Filename of the airport data file as a string, e.g., "groundnet", "ils", "jetways", "rwyuse", "threshold", or "twr". See above for its use in the concatenation of the path. |
| |param3 = target | | |param3 = target |
− | |param3text = Optional place to put the results in the [[Property Tree]]. May be either a <code>props.Node</code> object or a property path. | + | |param3text = Optional place to put the results in the [[Property Tree]]. May be either a <code>props.Node</code> object pointing to a place in the Property Tree or a property path. |
| |example1 = var data = io.read_airport_properties("KSFO", "ils"); # the airport might need changing | | |example1 = var data = io.read_airport_properties("KSFO", "ils"); # the airport might need changing |
| props.dump(data); # dump data | | props.dump(data); # dump data |
Line 210: |
Line 210: |
| === read_properties() === | | === read_properties() === |
| {{Nasal doc | | {{Nasal doc |
− | |syntax = io.read_airport_properties(path[, target]); | + | |syntax = io.read_properties(path[, target]); |
− | |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. | + | |text = Loads an XML file. Returns the data as a <code>props.Node</code> on success or <code>'''nil'''</code> on error. Note that the file ''must'' be in the [[PropertyList XML files|PropertyList]] format, or else the function will fail. |
| |param1 = path | | |param1 = path |
− | |param1text = Path to the XML file. | + | |param1text = Path to the XML file as a string. |
| |param2 = target | | |param2 = target |
− | |param2text = Optional place to put the results in the [[Property Tree]]. May be either a <code>props.Node</code> object or a property path. | + | |param2text = Optional place to put the results in the [[Property Tree]]. May be either a <code>props.Node</code> object pointing to a place in the Property Tree or a property path. |
− | |example1 = var target = props.globals.getNode("/sim/model"); | + | |example1 = var path = getprop("/sim/fg-root") ~ '/keyboard.xml'; |
− | io.read_properties("/tmp/foo.xml", target); | + | var data = io.read_properties(path); |
− | |example2 = var data = io.read_properties("/tmp/foo.xml", "/sim/model"); | + | props.dump(data); # dump data |
− | var data = io.read_properties("/tmp/foo.xml"); | + | |example2 = var path = getprop("/sim/fg-root") ~ '/keyboard.xml'; |
| + | var node = props.globals.getNode("demo", 1); |
| + | io.read_properties(path, node); |
| + | props.dump(node); # dump data |
| + | |example3 = var path = getprop("/sim/fg-root") ~ '/keyboard.xml'; |
| + | var node = "/demo"; |
| + | io.read_properties(path, node); |
| + | props.dump(props.globals.getNode(node)); # dump data |
| }} | | }} |
| | | |