Can this be changed to a shared function that works for multiple instances as well as a single one? I don't want to nest “a1” and “a2” inside it.Because later, I also need to create separate paragraph styles “b1” and “b2” within that group.Is it possible to achieve something like this:`setParGroup([“b1”,“b2”])`That is, maintain the ability to create multiple styles at once while also allowing creation of a single style.Both should share the same SetParGroup1();
SetParGroup2();
function SetParGroup1() {
var wn = ["a1","a2"];
for (var i = 0; i < wn.length; i++) {
w = newParGroStyle(app.activeDocument, magGroParStn, wn[i])
};
}
function SetParGroup2() {
var wn = ["b1","b2"];
for (var i = 0; i < wn.length; i++) {
w = newParGroStyle(app.activeDocument, magGroParStn, wn[i])
};
}
function newParGroStyle(d, g, n,) {
// Get the group by name
var group = d.paragraphStyleGroups.itemByName(g);
// If group exists, check or create style
if (!group.isValid)
group = d.paragraphStyleGroups.add({ name: g })
if (!group.parag