How i can save & load an array to project token?

Example Project


1D Array 
var Value_Buttons = [0,0]; 

function LoadData(){
   Value_Buttons = IR.GetVariable("Global.Data").split(",");    
   IR.Log(Value_Buttons)
}                

function SaveData(){
   IR.SetVariable("Global.Data", Value_Buttons);    
   IR.Log(Value_Buttons);
}

SaveData();
LoadData();

2D Array
var Value_Buttons = [[0,0],[1,1]]; 

function LoadData(){
   var data = IR.GetVariable("Global.Data");
   data = data.split(";");
   for(var i = 0; i < data.length; i++)
   Value_Buttons[i] = data[i].split(",");
   IR.Log(Value_Buttons)
}   

function SaveData(){
   var data = "";
   for(var i = 0; i < Value_Buttons.length; i++)
   data += Value_Buttons[i] + ";";
   IR.SetVariable("Global.Data", data);
   IR.Log(data);
}

SaveData();
LoadData();
3D Array
var Value_Buttons = [[[0,0],[1,1]],[[2,2],[3,3]]]; 

function LoadData(){

   var data_1 = IR.GetVariable("Global.Data");
   var data_2 = [];
   data_1 = data_1.split(":");

   for(var i = 0; i < data_1.length; i++){
      data_2[i] = data_1[i].split(";");
      for(var j = 0; j < data_2[i].length; j++)
         Value_Buttons[i][j] = data_2[i][j].split(",");  
   }
   IR.Log(Value_Buttons);

}                                      

function SaveData()
{
   var data = "";
   for(var i = 0; i < Value_Buttons.length; i++){
      for(var j = 0; j < Value_Buttons[i].length; j++){
         data += Value_Buttons[i][j];         

         if(j < Value_Buttons[i].length -1)
            data += ";"
      }          

      if(i < Value_Buttons.length -1)
         data += ":";
   }

   IR.SetVariable("Global.Data", data);
   IR.Log(data);
}

SaveData(); 
LoadData();
<br/>

This article was helpful for 2 people. Is this article helpful for you?