Login Page - Create Account

Support Board


Date/Time: Sat, 20 Oct 2018 22:41:07 +0000



SetString outside of default block

Support Request:
[2016-07-13 06:08:53]
onnb - Posts: 499
See code below. If I run it, I see "tmp" printed once on sc.Index == 0 and then I see "Invalid" for the rest. Is that expected?


SCSFExport scsf_test_string(SCStudyInterfaceRef sc)
{
  REFS;

  if (sc.SetDefaults)
  {
    sc.GraphName = "Test String";
    sc.StudyDescription = "";
    sc.AutoLoop = 0;
    sc.GraphRegion = 0;
    sc.UpdateAlways = 1;
    sc.FreeDLL = 0;


    return;
  }

  if (sc.Index == 0)
    sc.Input[0].SetString("tmp");


  SCString str = sc.Input[0].GetString();

  sc.AddMessageToLog(str, 0);

[2016-07-13 06:11:26]
Sierra Chart Engineering - Posts: 65034
That very well could be due to performance reasons .
Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. If possible please keep your questions brief and to the point. Please be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

If your question/request has been answered and you do not have anything further, then it is easiest for us if you do not reply again to say thank you.
[2016-07-13 06:34:29]
onnb - Posts: 499
Just to make sure I understand - its not possible to SetString outside of the SetDefaults block?
[2016-07-13 06:51:44]
Sierra Chart Engineering - Posts: 65034
This is an incomplete question. What are you trying to set the text string on? If it is a Study Input, try and see what happens. We do not know the answer without careful examination of the code.
Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. If possible please keep your questions brief and to the point. Please be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

If your question/request has been answered and you do not have anything further, then it is easiest for us if you do not reply again to say thank you.
[2017-12-03 21:21:48]
onnb - Posts: 499
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);
}




[2017-12-04 12:15:19]
Sporken - Posts: 81
Different user here:

I just tested this as well and got the same result. Building with VS2017 v15.3.4

I tested with optimizations on and off using #pragma with this code

#pragma optimize( "", off )
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);
}
#pragma optimize( "", on )

Sierra charts version is 1656.

I have also recently seen a strange, unexplained, possibly related/unrelated text problem on my "Add Study" window. Occasionally my custom Study names (that come from SCSFExport scsf_studyname) are corrupted with log messages from the study itself. Messages that are output AFTER the SetDefaults block.
So an entry in the Add Study window would read, literally

"scsf_Jason_LiveStudyLoadDataFromFile : %s %s ---- Checking Hash before reading "

So the text is showing the %s %s from the code text rather than being the output of the execution of that string through the Format command.
I've been trying to track down the problem for at least the last month but it keeps "fixing itself" and then reappearing.

This might be unrelated or perhaps there's a problem with stack/heap corruption or perhaps the lifespan of SCString objects is causing the same memory to be reused.

I tested this again with an entirely fresh empty chart and it filled my log window very rapidly with this -

Chart: ESZ17 [M] 1 Min #1 | Study: Test String | str1_updated str2_updated | 2017-12-04 12:59:41
Date Time Of Last Edit: 2017-12-04 12:20:50
[2017-12-04 12:24:51]
Sporken - Posts: 81
It appears that my SupportBoard message has been truncated and I've lost the original text. Perhaps you can still see what I wrote.
[2017-12-04 18:55:45]
Sierra Chart Engineering - Posts: 65034
We removed the Message Log. It was just too long and unnecessary, and it did get truncated by the Support Board after a certain point.

We will be looking into the Input name string issue today.

are corrupted with log messages from the study itself.
Most likely this is going to be a problem in your own code.
Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. If possible please keep your questions brief and to the point. Please be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

If your question/request has been answered and you do not have anything further, then it is easiest for us if you do not reply again to say thank you.
Date Time Of Last Edit: 2017-12-04 18:56:08
[2017-12-05 11:18:39]
Sierra Chart Engineering - Posts: 65034
This is now resolved.
Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. If possible please keep your questions brief and to the point. Please be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

If your question/request has been answered and you do not have anything further, then it is easiest for us if you do not reply again to say thank you.
[2017-12-05 16:07:39]
onnb - Posts: 499
What version is this resolved in?
[2017-12-05 18:22:09]
Sierra Chart Engineering - Posts: 65034
Prerelease 1658.
Sierra Chart Support - Engineering Level

Your definitive source for support. Other responses are from users. If possible please keep your questions brief and to the point. Please be aware of support policy:
https://www.sierrachart.com/index.php?l=PostingInformation.php#GeneralInformation

If your question/request has been answered and you do not have anything further, then it is easiest for us if you do not reply again to say thank you.

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

Login


Login Page - Create Account