From 71f80dff348d1fe3a5508049b5231aae66c0440e Mon Sep 17 00:00:00 2001 From: mfranz Date: Thu, 4 Dec 2008 11:30:44 +0000 Subject: [PATCH] initNode: add fourth optional parameter: "force", which enforces a type, so n.initNode("whatever", 1 "BOOL", 1); will make node n a BOOL even if it was "DOUBLE" before. Default: 0. An existing value will be retained, though. --- Nasal/props.nas | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Nasal/props.nas b/Nasal/props.nas index 0f779108c..9058cdae8 100644 --- a/Nasal/props.nas +++ b/Nasal/props.nas @@ -127,11 +127,13 @@ Node.getValues = func { # The third, optional argument is a property type (one of # "STRING", "DOUBLE", "INT", or "BOOL"). If it is omitted, then # "DOUBLE" is used for numbers, and STRING for everything else. -# Returns the property as props.Node. +# Returns the property as props.Node. The fourth optional argument +# enforces a type if non-zero. # -Node.initNode = func(path = "", value = 0, type = nil) { +Node.initNode = func(path = "", value = 0, type = nil, force = 0) { var prop = me.getNode(path, 1); if(prop.getType() != "NONE") value = prop.getValue(); + if(force) prop.clearValue(); if(type == nil) prop.setValue(value); elsif(type == "DOUBLE") prop.setDoubleValue(value); elsif(type == "INT") prop.setIntValue(value);