Author Topic: One-time variable initialization  (Read 77 times)

I'm not sure if this is currently possible with existing function graph nodes, but I don't believe it is. What I think would be very beneficial is something along the lines of a static c/c++ variable, where the initial value is applied when you declare it, but that code is ignored every other time it is encountered.


int MyFunctionGraph()
    static int myVar = 1;
    myVar = myVar + 1;
    return myVar;

It is currently possible to do all of this except the first line. C/C+ will execute that first line the very first time this function is called (technically, I think it happens before that, but that's irrelevant), but then never again. Maybe we could have some type of variable initialization node that gets bypassed after it is used once? Or just anything to avoid having to set initial values in separate function graphs.

EDIT UPDATE: Found out about the sequence node after writing this. It helps a little, but it would still be great to have some type of variable initialization node.

Last Edit: February 17, 2019, 02:07:58 am