persistant variable in scripts not in delphi

Hi,
we have script like:

var
watchdog: integer; // this one should be persistent, static
begin
watchdog := watchdog + 1; // with each execution it should increment
end;

We use timer to repeatedly execute this script. It seems that watchdog is not global, static.
variable is always the same.
Because we used some other scripting where this was possible, we ask if there is another way to implement this. We want to use local static variables in script and not in delphi.

Thank you,
Vojko Cendak

Vojko Cendak

All scripter variables are variants that are initialized to null at the beginning. Thus, if you sum 1 to null, you get null. You need to initialize the variable:

var
  watchdog: integer; 

begin
  if VarIsNull(watchdog) then watchdog := 0;
  watchdog := watchdog + 1; 
end;                           

thank god, it's working this way. Now we don't need to change so much.

Maybe you could add this to help or examples.

all the best, Vojko

1 Like