Quote:
Originally Posted by ownedbycats
I managed to figure this, perhaps a bit clumsily -- also changed some of the reference names to be a bit clearer
Code:
program:
...
if new_colls == '' then existing_colls = $#kobocoll fi;
if new_colls then existing_colls = list_difference($#kobocoll, $#booktype, ',') fi;
if new_colls == '' then new_colls = strcat($#booktype, ',') fi;
merged_colls = list_union(new_colls, existing_colls, ',');
explanation:
new_colls generates a set of new collections with the strcat
existing_colls is taken from the existing #kobocoll value. If new_colls exists, it removes booktype from the list
If new_colls doesn't exist, it sets it to #booktype
merged_colls combines new_colls and existing_colls.
|
FWIW: this is a simplified version of what you wrote:
Code:
program:
...
if !new_colls then
existing_colls = $#kobocoll;
new_colls = $#booktype
else
existing_colls = list_difference($#kobocoll, $#booktype, ',')
fi;
merged_colls = list_union(new_colls, existing_colls, ',');