29
edits
Line 14: | Line 14: | ||
== subvec() == | == subvec() == | ||
Extract items of a vector | Extract items of a vector - equivalent to the left() function for a string | ||
Example : | Example : | ||
<syntaxhighlight lang="nasal" enclose="div"> | <syntaxhighlight lang="nasal" enclose="div"> | ||
var | var FGRoot = getprop("/sim/fg-root"); | ||
var filename = "/Aircraft"; | |||
var path_files = directory(FGRoot ~ filename); | |||
foreach(var key; path_files) { | |||
print(key); | |||
} | |||
</syntaxhighlight> | </syntaxhighlight> | ||
returns : ".", "..", " | returns : '''"." , ".." , "Generic", "Instruments", "Instruments-3d", "c172p", "ufo"''' | ||
With subvec(): | |||
<syntaxhighlight lang="nasal" enclose="div"> | <syntaxhighlight lang="nasal" enclose="div"> | ||
var | var FGRoot = getprop("/sim/fg-root"); | ||
var filename = "/Aircraft"; | |||
var path_files = subvec(directory(FGRoot ~ filename),2); | |||
foreach(var key; path_files) { | |||
print(key); | |||
} | |||
</syntaxhighlight> | </syntaxhighlight> | ||
returns : " | returns : '''"Generic", "Instruments", "Instruments-3d", "c172p", "ufo"''' | ||
<syntaxhighlight lang="nasal" enclose="div"> | <syntaxhighlight lang="nasal" enclose="div"> | ||
var | var FGRoot = getprop("/sim/fg-root"); | ||
var filename = "/Aircraft"; | |||
var path_files = subvec(directory(FGRoot ~ filename),3); | |||
foreach(var key; path_files) { | |||
print(key); | |||
} | |||
</syntaxhighlight> | </syntaxhighlight> | ||
returns : " | returns : '''"Instruments", "Instruments-3d", "c172p", "ufo"''' | ||
== delete() == | == delete() == |
edits