Login Page - Create Account

Support Board


Date/Time: Sat, 11 Jan 2025 00:46:50 +0000



Post From: You may have a bug

[2016-10-10 13:48:16]
bala - Posts: 74
case: Persistent vars lose value on testing for IF
++++++++++++++++++++++++++
SCSFExport scsf_Mytest2(SCStudyGraphRef sc)
{*****
******
int& testvar = sc.GetPersistentInt(10);
int a;

if (sc.INdex == 0){ testvar =100;}
if (sc.Index > 5){ a=testvar;}

// a should be 100 but actually it is 0. Is the persistent variable testvar loses it's value on the IF test?

// workaround
int& testvar = sc.GetPersistentInt(10);
int& testvarREF = sc.GetPersistentInt(10);
int a;

if (sc.INdex == 0){ testvar =100;testvarREF = testvar;}
if (sc.Index > 5){ a=testvarREF;}

// a shows a value of 100

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Thanks