Login Page - Create Account

Support Board


Date/Time: Tue, 26 Nov 2024 12:36:32 +0000



Post From: sc.Subgraph[].Name returns sc.Subgraph[].ShortName

[2023-12-05 11:31:27]
User462086 - Posts: 196
Hello SC. Using v2533. How can a study consistently access a subgraph's name?

Please refer to lines 3 & 4 of test study output:


#include "sierrachart.h"

SCDLLName("Test_SubgraphNameShortName")

SCSFExport scsf_Test_SubgraphNameShortName(SCStudyInterfaceRef sc){
  
  if (sc.SetDefaults){
    
    sc.GraphName  = "Test_SubgraphNameShortName";
    sc.AutoLoop   = 0;
    return;
  }
  
  int& executionCount = sc.GetPersistentInt(0);
  
  // add/remove 'ShortName' based on execution number
  
  if (executionCount == 0){
    
    sc.Subgraph[0].Name = "Name";
    sc.Subgraph[0].DrawStyle = DRAWSTYLE_LINE;
    sc.Subgraph[0].PrimaryColor = RGB(200,200,0);
    sc.Subgraph[0][sc.ArraySize-1] = sc.HLAvg[sc.ArraySize-1];
  }
  else if (executionCount == 10){
    
    sc.Subgraph[0].ShortName = "ShortName";
  }
  else if (executionCount == 20){
    
    sc.Subgraph[0].ShortName = "";
  }
  else if (executionCount > 30){
  
    return;
  }
  
  // increment execution count
  executionCount++;

  // write to log
  SCString debugMessage;
  debugMessage.Format("Name is: %s | ShortName is: %s"
             , sc.Subgraph[0].Name.GetChars()
             , sc.Subgraph[0].ShortName.GetChars());
  sc.AddMessageToLog(debugMessage, 0);
  
}

// OUTPUT:
// Name is: Name | ShortName is:
// Name is: Name | ShortName is: ShortName
// Name is: ShortName | ShortName is: ShortName
// Name is: ShortName | ShortName is:
// Name is: Name | ShortName is: