Login Page - Create Account

Support Board


Date/Time: Wed, 27 Nov 2024 15:34:03 +0000



[Programming Help] - ACSIL sc.StorageBlock (how to use this function)

View Count: 483

[2023-08-06 09:29:08]
User92573 - Posts: 530
Dear Support Board

I have a study where 2 values are updated via ACS Buttons. I want to retain the 2 updated study values from every chart in my chartbook that has this study loaded - so when they are reopened the last values/settings can be used.

Int Parameter_1 = 5;
Parameter_2 = 6;

I’ve read through the threads and manual and sc.StorageBlock which seems to be the solution, however I can’t find any examples of where to place the different items of code.


// ------------------------------------------------------
// Is this correct?
// ------------------------------------------------------


// Part 1 - Is this placed in the default block?

// This is the structure of our data that is to be stored in the storage block.

struct s_PermData
{
int i_Parammeter1_Stored;
int i_Parammeter2_Stored;
};


// Part 2 - Then in the do processing section where the changes are made

// Using the sc.StorageBlock
// After updating the values:

Parameter_1 = 11;
Parameter_2 = 12;

// Here we make a pointer to the storage block as if it was a pointer to our structure
// Where is this placed?

s_PermData* PermData;

PermData = (s_PermData*)sc.StorageBlock;


// Here we set data using the members of our structure. This uses the memory of the storage block

PermData-> i_Parammeter1_Stored = Parameter_1;
PermData-> i_Parammeter2_Stored = Parameter_2;



2 additional questions re the above:

-   When a chart or chartbook is deleted is the Storage Block automatically deleted or released?
-  I have 10 charts in a Chartbook and 3 Chartbooks in my chartbook group. Each chart has this study. Will each chart save to its own Storage Block?


Apologies for a long-winded thread but Storage blocks are a little beyond my ACSIL knowledge.

Any help appreciated

Many thanks.
[2023-08-06 18:01:18]
JohnR - User831573 - Posts: 306
using the search in NotePad++ looking within ACS_Source I was able to find the below within Studies.cpp --> around line 4485


/*============================================================================
  This function is an example of using the storage block.
----------------------------------------------------------------------------*/
SCSFExport scsf_StorageBlockExample(SCStudyInterfaceRef sc)

Hope this helps,
JohnR
[2023-08-06 21:38:07]
User92573 - Posts: 530
John,

Thank you so much I'd missed that example and obviously my first thoughts above were wrong so it was a huge help.

Do you know if the storage block is removed when a chart/chartbook is deleted?

Again, many thanks.
Date Time Of Last Edit: 2023-08-06 21:41:31
[2023-08-07 02:54:44]
JohnR - User831573 - Posts: 306
I have not used that capability.

Sorry, I'm no more help,
John
[2023-08-07 10:16:37]
User92573 - Posts: 530
Thank you John.

I'm pretty sure that's handled by the SC function.
Date Time Of Last Edit: 2023-08-07 12:01:43

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

Login

Login Page - Create Account