HISE Logo Forum
    • Categories
    • Register
    • Login

    Using concatenation for key in object?

    Scheduled Pinned Locked Moved Scripting
    2 Posts 2 Posters 57 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • VirtualVirginV
      VirtualVirgin
      last edited by

      I am trying to name the key for some key value pairs in an object, and I am stuck on concatenation.

      		local matrixTableReturnObject = 
      		{
      		 	name + "inputNameArray" : inputLabels,
      			name + "outputNameArray" : outputLabels.outputNameArray,
      			name + "outputLabelArray" : outputLabels.labelArray,
      			name + "outputPanelArray" : outputLabels.panelArray,
      			name + "outputLabelPanelArray" : outputLabels.labelPanelArray,
      			name + "outputClickPanelArray" : outputLabels.clickPanelArray,
      			name + "buttonMatrixArray" : buttonMatrix.buttonMatrixArray,
      			name + "inputOutputMatrixArray" : buttonMatrix.inputOutputMatrixArray
      								
      		};
      

      and I am getting this error:

      Interface:! GUI_Factory_Methods.js (277): Found '+' when expecting ':'
      

      This is inside an inline function which has an input parameter "name".
      How can I get it to concatenate properly to use as a key?

      You can listen to my orchestral mockups here:
      https://www.virtualvirgin.net/

      d.healeyD 1 Reply Last reply Reply Quote 0
      • d.healeyD
        d.healey @VirtualVirgin
        last edited by

        @VirtualVirgin

        local matrixTableReturnObject = {};
        
        matrixTableReturnObject[name + "inputNameArray"] = inputLabels;
        matrixTableReturnObject[name + "outputNameArray"] = outputLabels.outputNameArray;
        // etc.
        

        Libre Wave - Freedom respecting instruments and effects
        My Patreon - HISE tutorials
        YouTube Channel - Public HISE tutorials

        1 Reply Last reply Reply Quote 1
        • First post
          Last post

        8

        Online

        1.8k

        Users

        11.9k

        Topics

        104.0k

        Posts