395
edits
Philosopher (talk | contribs) m (→getprop()) |
Philosopher (talk | contribs) m (→setprop()) |
||
Line 97: | Line 97: | ||
=== <tt>setprop()</tt> === | === <tt>setprop()</tt> === | ||
Sets a property value for a given node path string. | Sets a property value for a given node path string. Returns 1 on success or 0 if the property could not be set (i.e. was read-only). | ||
<syntaxhighlight lang="nasal"> | <syntaxhighlight lang="nasal"> | ||
Line 103: | Line 103: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
All arguments but the last are concatenated to a path string, | All arguments but the last are concatenated to a path string, like getprop() above. The last value is written to the respective node. If the node isn't writable, then an error message is printed to the console. | ||
Examples: | Examples: | ||
Line 121: | Line 112: | ||
</syntaxhighlight> | </syntaxhighlight> | ||
'''Erasing a property from the property tree''': a property that has been created, for example through <tt>setprop()</tt> | '''Erasing a property from the property tree''': a property that has been created, for example through <tt>setprop()</tt> has to be erased using the props namespace helper, like this: | ||
<syntaxhighlight lang="nasal"> | <syntaxhighlight lang="nasal"> | ||
props.globals.getNode("foo/bar").remove(); # take out the complete node | props.globals.getNode("foo/bar").remove(); # take out the complete node | ||
props.globals.getNode(" | props.globals.getNode("foo").removeChild("bar"); # take out a certain child node | ||
</syntaxhighlight> | </syntaxhighlight> | ||
edits