From 39823ac8791c8b35e301190a697f851c8497054b Mon Sep 17 00:00:00 2001
From: Jonathan Wilkes <jon.w.wilkes@gmail.com>
Date: Sun, 29 Jan 2017 15:28:38 -0500
Subject: [PATCH] partial fix for #157: update secondary array attributes on
 "Apply" or "Ok"

---
 pd/nw/dialog_canvas.html | 13 +++++++------
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/pd/nw/dialog_canvas.html b/pd/nw/dialog_canvas.html
index d2ecdf607..d6d80cad1 100644
--- a/pd/nw/dialog_canvas.html
+++ b/pd/nw/dialog_canvas.html
@@ -539,7 +539,7 @@ function get_array_slot_4(attrs) {
 }
 
 function apply() {
-    var i, attrs, gop, hide_name, slot_4;
+    var gop, hide_name, slot_4;
     // If this is a dialog to create a new array, we
     // skip the canvas dialog callback
     if (!new_array_dialog) {
@@ -564,11 +564,13 @@ function apply() {
 
     // Now send the array properties, in a separate
     // message for each array
-    for (i = 0; i < pd_garray_attrs.length; i++) {
-        attrs = pd_garray_attrs[i];
+    pd_garray_attrs.forEach(function(attrs) {
+        var i;
         name = get_array_value("array_name", attrs);
         var arr = name.split("");
-        for (var i = 0; i < arr.length; i++) {
+        // This is a bit too complicated-- isn't there a standardized
+        // interface for doing this?
+        for (i = 0; i < arr.length; i++) {
             if (arr[i] === "$" && i+1 < arr.length &&
                 arr[i+1] >= "0" && arr[i+1] <= "9") {
                 arr[i] = "#";
@@ -587,8 +589,7 @@ function apply() {
             get_array_value("array_fill", attrs),
             get_array_value("array_outline", attrs)
         );
-
-    }
+    });
 }
 
 function cancel() {
-- 
GitLab