Login Page - Create Account

Support Board


Date/Time: Wed, 12 Mar 2025 11:52:51 +0000



Post From: Vector losing it's value ACSIL (need persistent vector)

[2024-12-24 12:31:36]
Balazs - Posts: 13
Thanks for the fast reply. Just to give some context: I have read every letter of the documentation. I think I grasp the core of STL_vectors, classes, ect. I have implemented the examples from the sierra website including some code they refer to in their ASC_source folder. and again, the code works fine it does what it needs to, to the extent of creating the vector, setting everything to NULL, initiating a persistentpointer, etc. It just loses the values wehn a new bar comes to the chart.

I could refer to a previous index [sc.Index-1] and reuse the vector at that index, however, I don't know if that is possible at all. The codes I tried give an error.

see code bellow. I cant seem to get past this issue. So if you have any concrete code tips, I would be more than gratefull.



//initiating the vector

std::vector<double>* InbLines;

  if(sc.LastCallToFunction)
  {
    if(InbLines != NULL)
    {
      delete InbLines;
      sc.SetPersistentPointer(1, NULL);
    }

    return;
  }

if (InbLines == NULL)
  {
    InbLines = new std::vector<double>;

    if(InbLines != NULL)
      sc.SetPersistentPointer(1, InbLines);
    else
    {
      sc.AddMessageToLog("Memory allocation error.", 1);
      return;
    }
  }



// doing some calculations, bla bla..



// lines 1 to 5 found in previous section adding them to the vector

if ( LineONE != 0)
  {
  InbLines->push_back(LineONE);
    
  CURRENT_keys++;  
  }
  
  
    if ( LineTWO != 0)
    {
      InbLines->push_back(LineTWO);
    
    
    CURRENT_keys++;
    }
  
      if ( LineTHREE != 0)
      {
        InbLines->push_back(LineTHREE);
  
  
      CURRENT_keys++;
      }
  
        if ( LineFOUR != 0)
        {
          InbLines->push_back(LineFOUR);
        CURRENT_keys++;
        }
  
  
          if ( LineFIVE != 0)
          {
            InbLines->push_back(LineFIVE);
  
          CURRENT_keys++;
          }
  }

// counting the number of elements and showing it at the bottom each bar via a Subgraph. This way I can count the amount of doubles inside the vector at a specific bar

NumbT[sc.Index] = InbLines->size();
  NumbOnLow[sc.Index] = NumbT[sc.Index];


Date Time Of Last Edit: 2024-12-24 12:45:25