Login Page - Create Account

Support Board


Date/Time: Wed, 27 Nov 2024 23:32:47 +0000



Post From: ACS Button - Show Hide Manual-loop study issue. Help appreciated.

[2023-06-30 10:58:22]
User92573 - Posts: 530
Dear Support Board

Any help appreciated with the following ACS Button/Study Show/Hide (add/remove) issue using a manual loop.

I have a small study that uses s_UseTool Tool (Horizontal Line). It works as expected but I'm having problems turning it on/off, or removing and re-applying via an ACS Button.

It works fine when I use the Study Settings Inputs.

Ticking the 'Hide Study' is picked up by 'sc.HideStudy' and on my input menu '3 lines below un-commented' it also shows and hides the study as expected.

I suspect its related to the manual-loop. I don't want to re-appy it as I have a menu event as a trigger. I just cannot seem to get it to work.

I know there are some great programmers out there so any help much appreciated.


// Abbreviated code:

SCInputRef Input_Show_Hide_Study = sc.Input[7];
SCInputRef Input_ACS_Button = sc.Input[8];

// Manual for efficiency as just using a Horizontal Line.
sc.AutoLoop = 0;


//Set Defaults
Input_Show_Hide_Study.Name = "Show Study"; // I can set this manually via the Study Settings form but also want to use the ACS Button.
Input_Show_Hide_Study.SetYesNo(1);

Input_ACS_Button.Name = "ACS Button to use";
Input_ACS_Button.SetInt(20);

//-------------------------------------------------------------------------------------------------  

// Do data processing

// This uses the setting from the Study Setting form. It is only applied when the "Hide Study" check box is ticked.
if (sc.HideStudy)
  return;


// These 3 lines of code allow me to set Show Hide from my Setting Inputs. Commented out while I try and do the same from the ACS Buttons.
// if(Input_Show_Hide_Study.GetYesNo() == 0)
// {  
  // return;
// }


//-------------------------------------------------------------------------------------------------
// ACS Button    
//-------------------------------------------------------------------------------------------------  

  
if (sc.LastCallToFunction || sc.HideStudy)
{

  // Set default hover text and button text for 'LastCallToFunction'
  sc.SetCustomStudyControlBarButtonHoverText(Input_ACS_Button.GetInt(), "");
  sc.SetCustomStudyControlBarButtonText(Input_ACS_Button.GetInt(), "");

  // Remove menu items when study is removed
  sc.RemoveACSChartShortcutMenuItem(sc.ChartNumber, Input_ACS_Button.GetInt());

  return;

}

if (sc.IsFullRecalculation)
{
  
  sc.SetCustomStudyControlBarButtonHoverText(Input_ACS_Button.GetInt(), "Show / Hide Study");
  sc.SetCustomStudyControlBarButtonText(Input_ACS_Button.GetInt(), "SHOW/HIDE");  
    
  sc.SetCustomStudyControlBarButtonEnable(Input_ACS_Button.GetInt(), 0);  

}


//-------------------------------------------------------------------------------------------------
// ACS Buttons - Actions    
//-------------------------------------------------------------------------------------------------

if(sc.MenuEventID == Input_ACS_Button.GetInt())
{  
  
  if(Input_Show_Hide_Study.GetYesNo() == 1) // Currently Set to Show
  {    
    Input_Show_Hide_Study.SetYesNo(0); // Swap to Hide/remove
  }
  else if(Input_Show_Hide_Study.GetYesNo() == 0) // Currently Set to Hide
  {
    Input_Show_Hide_Study.SetYesNo(1); // Swap to Show/apply    
  }

  
  // The message log correctly shows the changes on every click as: Show Hide = 1, Show Hide = 0, Show Hide = 1 etc.
    
  msg.Format("Show Hide %i",Input_Show_Hide_Study.GetInt());
  sc.AddMessageToLog(msg,1);


  // This now hides the study as the value is the same as if my user input hade be set to 'Input_Show_Hide_Study.SetInt(0)'
  // and viewing the 'Input_Show_Hide_Study' shows it's value has changed.

  // But I'm not sure how to just refresh the study as code the below does not complete the 'return' and hence remove the
  // Line Tool as expected, unless I open and close the studies form.


  if(Input_Show_Hide_Study.GetYesNo() == 0)
  {  
    return;
  }  


}


A little stumped on this so any help appreciated. Possibly misunderstood the method required to show/hide or add/remove a Tool via the ACS Buttons/Menu Event?

Many thanks