Login Page - Create Account

Support Board


Date/Time: Sat, 18 May 2024 19:03:26 +0000



Post From: Setting Persistent variables in the sc.SetDefaults Code Block

[2020-03-12 12:00:41]
kas64h - Posts: 87
Please note the following issue occurs only when a Study already exists on a chart, and that chart is being OPENED, not when ADDING a fresh study to a chart.

I'm setting persistent varibles in the sc.SetDefaults Code Block, which are not persisted after the initial call to set the Defaults of the study. For example:

int &Initializing = sc.GetPersistentInt(0);

if (sc.SetDefaults)
{
Initializing = 2;
return;
}

The Initializing persistent variable is being successfully set inside the sc.SetDefaults Code Block, but on the next call to do the Full Recalculation, Initializing is 0 (i.e. it hasn't been persisted).
I know this used to work, and thought this was still the intended behaviour (sc.GetPersistentInt())

This behaviour seems to be for any persistent variable, not just Ints

Persistent variables defined and set after the sc.SetDefaults Code Block are still working fine.