Persistent Variable Never Goes Away

I thought I would bump this topic because I have R9.6 and I thought this might warrant a fresh one

Here’s what happens to me:

I Initialize a persistent table with the following values:

I don’t want element 12 so I comment it out in my strategy:

But it’s still there:

OK. So I configure the strategy to initialize when it runs. Works great. I

But I want it to be persistent so I configure the table accordingly and presto!
It’s baaack…


The way I made it go away the first time was to delete and recreate the table. After messing with it for awhile I found I could remove the offending element while the strategy was running, apply it, and then it wouldn’t come back.

Why is this happening?



Well, that’s the way it is supposed to work :grinning:

If you are initializing a persistent variable every time your strategy starts - then it doesn’t need to be a persistent variable. A regular variable will do the same exact thing. Typically I conditionally initialize persistent variables so they have sane values on a newly programmed controller:

if(nMyPersistent_pstv == 0) then
  nMyPersistent_pstv = 500; //Set to sane default - this will only ever get called one time (unless the user sets the value to 0 or we download to a new controller

When you removed the initialization statement, the persistent var, still “persisted” with the last value you gave it - restarting the strategy will not clear persistent vars, that is the whole point of them.

The way you are using your string table - you probably don’t need a persistent table. If you wanted to be able to change the names of your sets without having to perform a download, then you would have them be persistent and you would NOT initialize them in the strategy - you will fill them in at runtime or perform a conditional initialization like I showed above.