tags:

views:

135

answers:

2

In one of my function objects (a global function) I'd like to transport the value of a few variables from one invocation of the function to the next. In C or C++ I'd use the 'static' keyword here.

I could be using global variables but that's quite ugly and it makes it hard to import this function into other PowerScript objects; I'd like the .srf file to be self-contained.

Does anybody know alternative ways for variables to keep their values? FWIW, the script function is called via PBNI.

+1  A: 

Create a window (w_data) with an instance variable

int i = 0

Make sure that the visible attribute is unchecked.

From your application, you open it

open (w_data)

then from a button

messagebox("", w_data.i)

w_data.i = w_data.i + 1

The value is incremented after each button click.

RealHowTo
+1  A: 

I believe there's ways to hack variables into global functions, but the intended design would be to put the function on a custom class, probably autoinstantiated, and create a shared variable. The shared variable value will survive even though the object gets destroyed.

Good luck,

Terry.

Terry
Thanks! This seems to be the cleanest solution; I'll follow this path.
Frerich Raabe