Scriptlets
Scriptlets copied to clipboard
Improve 'set-constant' — automatic creation of the chain of parent objects if necessary
Sometimes it happens that a constant needs to be set, for which parent object(s) must also be created.
For example, if I want to set foo.bar to a trueFunc, I have to do the following:
! First, create the 'foo' object
example.com#%#//scriptlet('set-constant', 'foo', 'emptyObj')
! Then, create the property
example.com#%#//scriptlet('set-constant', 'foo.bar', 'trueFunc')
However, perhaps the 2nd rule would be enough by itself:
- if
fooexists and is an object, simply set thebarproperty totrueFunc - if
foodoes not exist, simply create it as an empty object and then set thebarprop - if
fooexists but is not an object, there are two options:- skip the execution of the scriptlet and do nothing
- or overwrite it with an empty object (if possible) and then set the
barprop