this is a FreePlane Groovy code. The task is to extract the node details and cast it to integer, or leave it equal to 1 if details are null (empty) or non-numeric. Initially, node details contain only "4" in plain text layout.
Here is my code:
def getRepetitions(node)
{
if (node.details!=null){
node['node.details']=node.details
node['node.details.size()']=node.details.size()
node['getPlain()']=node.details.getPlain()
node['getPlain().size()']=node.details.getPlain().size()
node['node.details.status']='not null'
getRepetitions=(double)(node.details.getPlain())-48
}else{
node['node.details.status']='null'
getRepetitions=1
}
}
Here is a problem, as code doesn't convert text "4" to 4, but rather to 52 (which is incidentally ASCII code of "4"). And worse, when I substract 48, so that the difference is equal to number itself, it doesn't pay attention.
I wouldn't be posting this, if such functions as toNumber(...) or .to.num0 would work, but when trying to implement this I see
"message: No signature of method: org.freeplane.plugin.script.proxy.Proxy$NodeRO.toNumber() is applicable for argument types: (java.lang.String) values: [4]Line number: -1Result:No signature of method: org.freeplane.plugin.script.proxy.Proxy$NodeRO.toNumber() is applicable for argument types: (java.lang.String) values: [4] at line -1"
Thanks in advance.