395
edits
Philosopher (talk | contribs) m (<syntaxhighlight>) |
Philosopher (talk | contribs) |
||
Line 412: | Line 412: | ||
var pi = func(target, data) { print("processing instruction: target=", target, " data=", data) } | var pi = func(target, data) { print("processing instruction: target=", target, " data=", data) } | ||
parsexml("/tmp/foo.xml", start, end, data, pi); | parsexml("/tmp/foo.xml", start, end, data, pi); | ||
</syntaxhighlight> | |||
=== <tt>resolvepath()</tt> === | |||
SimGear features its own [[Resolving Paths|path resolving framework]] that takes a relative path and returns an absolute path, checking from base directories such as [[$FG_ROOT]], [[$FG_HOME]], [[$FG_AIRCRAFT]], and the current aircraft directory (<tt>/sim/aircraft-dir</tt>). This function in Nasal takes a path string and returns the absolute path or an empty string if the path couldn't be resolved. | |||
Example: | |||
<syntaxhighlight lang="php"> | |||
var guess_path = func(path...) { | |||
var path_concat = string.join(path, "/"); | |||
var file_path = resolvepath(path_concat); | |||
if (file_path == "") die("Path not found: "~path_concat); | |||
return file_path; | |||
} | |||
</syntaxhighlight> | </syntaxhighlight> | ||
edits