Login Page - Create Account

Support Board


Date/Time: Tue, 26 Nov 2024 22:38:33 +0000



Unable to delete all s_UseTool items

View Count: 258

[2023-10-19 13:02:39]
User907967 - Posts: 54
Hi, I am keen to find out why I can't seem to be able to delete all the drawings upon study closure (all at once).

The function that triggers the deletion:
  int i = 0;
  s_UseTool j;
  while (sc.GetUserDrawnChartDrawing(sc.ChartNumber, DRAWING_UNKNOWN, j, i)) {
    sc.DeleteUserDrawnACSDrawing(sc.ChartNumber, j.LineNumber);
    i++;
  }

I run the above when the below happens:
  
if (sc.LastCallToFunction == true)

Every time I do that, there are several drawings still left on the chart.

What am I missing? Is this a bug?

Before you ask, I need to be able to copy these drawings on other charts so I can only use user drawings.

Thoughts?
[2023-10-19 13:34:10]
User907968 - Posts: 823
What am I missing? Is this a bug?
Yes, it is a bug in your code.


while (sc.GetUserDrawnChartDrawing(sc.ChartNumber, DRAWING_UNKNOWN, j, i)) {
sc.DeleteUserDrawnACSDrawing(sc.ChartNumber, j.LineNumber);
i++;
}

You are deleting an item from the index, but still incrementing, therefore every other drawing is skipped over.
The increment is not needed if the call to delete is successful.
[2023-10-19 13:41:52]
User907967 - Posts: 54
Thank you so much. You are right. I should have realised that.

To post a message in this thread, you need to log in with your Sierra Chart account:

Login

Login Page - Create Account