Login Page - Create Account

Support Board


Date/Time: Mon, 22 Jan 2018 06:39:42 +0000



Post From: SetString outside of default block

[2017-12-04 12:15:19]
Sporken - Posts: 76
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