VS: error at left operand?

Jan Schenkel janschenkel at yahoo.com
Tue Oct 15 06:16:01 CDT 2002


--- Esa_Kivelä <Esa.Kivela at ncrc.fi> wrote:
> 
> 
> > -----Alkuperäinen viesti-----
> > Lähettäjä: Richard Gaskin
> [mailto:ambassador at fourthworld.com]
> > Lähetetty: 15. lokakuuta 2002 12:05
> > Vastaanottaja: use-revolution at lists.runrev.com
> > Aihe: Re: error at left operand?
> > 
> > 
> > Esa Kivelä wrote:
> > 
> > > I have code:
> > > 
> > > on idle
> > > set the itemdel to ","
> > > put item 1 of field "huu" + item 1 of field
> "buu" + item 1 
> > of field "suu" into
> > > field "28"
> > > 
> > > end idle
> > > 
> > > and I get error message: "  * There was an
> Execution Error 
> > at 10:58:55 AM
> > > Error description:  Operators +: error in left
> operand
> > > Object: field id 1066 of card id 1002 of stack
> "C:/Program 
> > Files/Revolution
> > > 1.1.1/resusrssikortti.rev"
> > > --------------------
> > > put item 1 of field "huu" + item 1 of field
> "buu" + item 1 
> > of field "suu" into
> > > field "28"
> > > --------------------"
> > > 
> > > What that mean?
> > 
> > Try clarifying it for the interpreter with
> parentheses:
> > 
> >  put (item 1 of field "huu") + (item 1 of field
> "buu") + 
> > (item 1 of field
> > "suu") into field "28"
> > 
> > Also, make sure the data in item 1 is numeric.
> 
> That error message gomes when text field is empty or
> there is one space (spacebar) in the
> field...werid...
> 
> EsaK 


Hi Esa,

Might I suggest a different approach?

- In all the data fields that need to be summed up,
set the script to:
  on closeField
    -- is only sent if something has changed
    send "calculateMe" to field "28"
  end closeField

- Now set the script of the "sum" field to
  on calculateMe
    -- calculate the sum of the part fields
    put "huu,buu" into tFields
    -- you can add more fields above
    repeat for each item tItem of tFields
      get item 1 of field tItem
      -- the default itemDelimiter is a comma anyway
      if it is not a number then add it to tSum
    end repeat
    put tSum into me
  end calculateMe

Now the sum will only be updated whenever any of the
parts changes, not gobbling up CPU cycles when nothing
has to be recalculated.
Plus, it checks for empty fields and doesn't try to
add those, avoiding the problem.

Hope this helped,

Jan Schenkel.

=====
"As we grow older, we grow both wiser and more foolish at the same time."  (La Rochefoucauld)

__________________________________________________
Do you Yahoo!?
Faith Hill - Exclusive Performances, Videos & More
http://faith.yahoo.com



More information about the use-livecode mailing list