546
edits
Red Leader (talk | contribs) m (Reverted edits by Mhab (talk) to last revision by Red Leader) Tags: Mobile edit Mobile web edit |
m (→resolvepath()) |
||
| Line 1,992: | Line 1,992: | ||
|syntax = resolvepath(path); | |syntax = resolvepath(path); | ||
|source = {{flightgear file|src/Scripting/NasalSys.cxx|l=604|t=Source}} | |source = {{flightgear file|src/Scripting/NasalSys.cxx|l=604|t=Source}} | ||
|text = Takes a relative path as a string and uses [[SimGear]]'s path-resolving framework to return an absolute path as a string. If the path could not be resolved, an empty string is returned. See [[Resolving Paths]] for a detailed description of the algorithm. | |text = Takes a relative path as a string and uses [[SimGear]]'s path-resolving framework to return an absolute path as a string. If the path could not be resolved, an empty string is returned. See [[Resolving Paths]] for a detailed description of the algorithm. This function can also be used to check if a file exists. | ||
|param1 = path | |param1 = path | ||
|param1text = Relative path to be completed. | |param1text = Relative path to be completed. | ||
|example1 = print(resolvepath("Nasal/globals.nas")); # prints the equivalent of $FG_ROOT/Nasal/globals.nas | |example1 = print(resolvepath("Nasal/globals.nas")); # prints the equivalent of $FG_ROOT/Nasal/globals.nas | ||
|example2 = print(resolvepath("blah")); # prints nothing; could not be resolved | |example2 = print(resolvepath("blah")); # prints nothing; could not be resolved | ||
|example3 = var file_path = resolvepath("Aircraft/SenecaII/some-file"); | |||
if (file_path != "") | |||
gui.popupTip("some-file found", 2); | |||
else | |||
gui.popupTip("some-file not found", 2); | |||
}} | }} | ||
edits