databank.addMissingFields
(+databank)
Create fields missing from a list, and assign them a default value
Syntax
db = databank.addMissingFields(db, names, value)
Input arguments
db
[ struct | Dictionary ]
Input databank that will be checked for
names
, and new fields will be created for the names missing, assigned a defaultvalue
.
names
[ string ]
List of field names; any field listed in
names
that does not exist in thedb
will be created indb
and assigned the defaultvalue
.
values
[ * ]
A default value for fields that are missing from the
names
.
Output arguments
db
[ struct | Dictionary ]
Output databank will all the
names
guaranteed to exist in it.
Description
Examples
Make sure that field names "a", "b", and "c" all exist in a databank; if
not, create them and assign NaN
:
d = struct();
d.a = 1;
d = databank.addMissingFields(d, ["a", "b", "c"], NaN);