[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: returning value of previous calc?



PureBytes Links

Trading Reference Links

It appears that you are assuming (hoping <g>) that the simple function variables
are static i.e. remain intact when function has finished executing. The result
you are getting is telling you that the simple function variables are dynamic
i.e. recreated on function entry and destroyed upon function exit. I'm also
fighting with series functions - the fact that series functions are "pulled out"
(as Mark Jurik put it) and solved before the rest of the code poses a number of
limitations.

Earl

-----Original Message-----
From: Gary Funck <gary@xxxxxxxxxxxx>
To: omega-list@xxxxxxxxxx <omega-list@xxxxxxxxxx>
Date: Wednesday, February 25, 1998 1:19 PM
Subject: returning value of previous calc?


>I've got a function that performs some caculations, and it creates
>a vector (1-d array) of results.  I know it is doing that, because
>it writes the values to a file.
>
>I wanted to call the function repetitively, after the initial call,
>with an arg. which is the index into the result array, and have the
>function return the value at that index, which was previously
>calculated.
>
>Instead, it seems that the value returned is simply the intial value
>that the array is set to.  The function is declared as "simple" not
>"series", because I want to be able to pass args. that are not constant
>into the function.  So, I can't use the trick of fetching a prior value
>of the array.
>
>Is my understanding correct, that I can't fetch the prior array
>calculations on subsequent calls to the function?
>
>
>Here's the block diagram for the current logic of my function:
>
>function f(x, len, n) (simple)
>...
>array: calc[50](0);
>if n >= 1 and n <= 50 then begin
>    { return the result of the previious calculation }
>    f = calc[n];
>end else begin
>    { .... do the calculations ....}
>    for ix = 1 to 50 begin
> calc[ix] = { something complicated (and slow) };
>    end;
>    f = 0: { this first returned value doesn't matter }
>end;
>
>
>The caller (an indicator/system) is trying to do this:
>
>array: calc[50](0);
>
>    { pass in n=0 to initialize the calculation. }
>    value1 = f(C, 20, 0);
>    for ix = 1 to 50 begin
> { pass in n > 0 to retrieve the previous calculations }
> calc[ix] = f(C, 20, ix);
>    end;
>
>
>Before you answer "global variables!" and send me a URL to the
>page describing how I can obtain the package (grin), is there anything
>like the above set up that will work?
>
>--
>--
>| Gary Funck,  Intrepid Technology, gary@xxxxxxxxxxxx, (650) 964-8135
>