Login Page - Create Account

Support Board


Date/Time: Sat, 27 Apr 2024 03:42:51 +0000



Post From: SetString outside of default block

[2017-12-03 21:21:48]
onnb - Posts: 660
Following up on this thread, hope this following will make it more clear

Using the code below, whenever I hit Insert (recalculate the chart), the last 4 lines in the message log look like this

Chart: ESZ17 5 Min #1 | Study: Test String | str1_updated str2_updated | 2017-12-03 16:10:24
Chart: ESZ17 5 Min #1 | Study: Test String | str1_updated str2_updated | 2017-12-03 16:10:24
Chart: ESZ17 5 Min #1 | Study: Test String | str1_updated str2_updated | 2017-12-03 16:10:24
Chart: ESZ17 5 Min #1 | Study: Test String | INVALID str2_updated | 2017-12-03 16:10:25

Notes on this
1. Notice on the live bar Input[0] is INVALID
2. This is 100% consistent
3. Input[0] is updated correctly in the study settings. Meaning it changes from str1 to str1_updated


SCSFExport scsf_test_string(SCStudyInterfaceRef sc)

{
  SCInputRef str1 = sc.Input[0];
  SCInputRef str2 = sc.Input[1];

  if (sc.SetDefaults)

  {

    sc.GraphName = "Test String";
    sc.StudyDescription = "";
    sc.AutoLoop = 1;
    sc.GraphRegion = 0;
    sc.FreeDLL = 0;

    str1.Name = "Str1";
    str1.SetString("str1");

    str2.Name = "str2";
    str2.SetString("str2");

    return;

  }

  if (sc.Index == 0)
    str1.SetString("str1_updated");

  if (sc.Index == sc.ArraySize-1)
    str2.SetString("str2_updated");

  SCString tmp1 = str1.GetString();
  SCString tmp2 = str2.GetString();

  SCString tmp3 = tmp1 + " " + tmp2;

  sc.AddMessageToLog(tmp1 + " " + tmp2, 0);
}