Ellen,

A couple of problems/concepts here.

(First, your clock is set a few hours into the future, so all 
responses show up before your question :) )

There is no need for any of the "global" statements in your 
"compute_prices" handler.  These variables are only used in that 
handler - that is the definition of a local variable.  just remove 
the global definitions.

The lines that acually call your function are:
    pvalue1 = float(-(1.0) * s * exp(-(divi1) * timeperiod) * \
               cum1_compute(-(1.0) * d1))
   pvalue2 = float(-(1.0) * x * exp(-(rate1) * timeperiod) * \
               cum1_compute(-(1.0) * d2))

If you really want to see what goes into and what comes out of your 
function call, I would suggest splitting these lines up.  This is a 
standard technique that I use for debugging.  For example, you could 
replace the above lines with something like:

    computedValue1 = cum1_compute(-(1.0) * d1))
    put "Passed in" && -(d1) && "returned:" && computedValue1
    pvalue1 = float(-(1.0) * s * exp(-(divi1) * timeperiod) * computedValue1

    computedValue2 = cum1_compute(-(1.0) * d2))
    put "Passed in" && -(d2) && "returned:" && computedValue2
    pvalue2 = float(-(1.0) * x * exp(-(rate1) * timeperiod) * computedValue2

This would allow you to really see what is being computed by your handler.

Next, if you don't use the built in Lingo debugger, I strongly 
suggest that you learn.  Please read my article on DOUG at:
   http://www.director-online.com/accessArticle.cfm?id=871

Next, the lines:

   --make a list of constant yy values
   yy=[:]
   yy = ["0.31938153","-(0.356563782)","1.781477937",\
        "-(1.821255978)","1.330274429"]

are just wierd.  There is no need to have the first one.  The second 
just replaces the value set by the first one.  And, there is no need 
to treat these values as strings, they should just be numbers, like 
this:
           yy = [0.31938153, -0.356563782, 1.781477937, -1.821255978, 
1.330274429]

If you make this change, you need to change the following line:

        fak1 = float(z * float(fak1 + value(yy[i])))

to the more simpler:

           fak1 = float(z * float(fak1 + yy[i]))

Finally, if you want/need a speed improvement, you can notice that 
the variables "yy" and "gamma" are constants (meaning that they never 
change their values), so there is no need to reassign their values 
every time you call your handler.  As an option you could do this:

global yy
global gamma

on startMovie
   yy = [0.31938153, -0.356563782, 1.781477937, -1.821255978, 1.330274429]
   gamma = 0.2316419
   -- anything else you may want to do in your startMovie handler
end

And then in your script member where you have your computation 
handlers, just add the lines
   global yy
   global gamma

at the top of the script, before your first handler.

Hope this helps.

Irv



At 5:09 PM -0700 6/15/01, Ellen C. Largo wrote:
>Hello lists,
>
>       I have this problem with the values returned after calling a function
>handler.  Below are the handler definitions.
>


><snip>



>       I tried to display the actual value computed with the 
>function handler and
>also the value actually computed in the calling handler, and i noticed that
>the calling function is using a different value in the computation than what
>was passed by the function handler.
>
>       I really am confused why is this so?  Is there something wrong with the
>computation or the passing of values?
>
>       The original formula for this computation is given to us in 
>Visual Basic
>code.
>
>       Also, is it really a must to declare variables used in 
>computation to be
>global in scope?  I tried declaring the variable vola1 as local (set vola1 =
>0.0) but when i test the value in the message window it returned a <VOID>
>value.  Why is this?
>
>

-- 

Lingo / Director / Shockwave development for all occasions. 
          
   (Home-made Lingo cooked up fresh every day just for you.)

[To remove yourself from this list, or to change to digest mode, go to
http://www.penworks.com/LUJ/lingo-l.cgi  To post messages to the list,
email [EMAIL PROTECTED]  (Problems, email [EMAIL PROTECTED])
Lingo-L is for learning and helping with programming Lingo.  Thanks!]

Reply via email to