help on adding value in temp variable
Alex Tweedly
alex at tweedly.net
Sun May 8 14:18:49 EDT 2005
Paul Salyers wrote:
> I got the above problem fixed, miss directed links.
>
Cool.
> however I'm now having this problem.
>
> on mouseUp
> put "+" into tFx -- Store the +
> for use later
> put tFx into field "Fx" -- See for sure
> the + is being stored
> put "1" into field "doWhat" -- program handler if
> the text of field "doWhat" = "1" do this else do this
> put field "Answer" into tfkey
> put value ( field "AddTo") Fx (tfkey) into field "AddTo" -- Add
> the fields together
>
> end mouseUp
>
>
> of I use
>
> on mouseUp
> --put "+" into tFx
> put tFx into field "Fx"
> put "1" into field "doWhat"
> put field "Answer" into tfkey
> put value ( field "AddTo") + (tfkey) into field "AddTo"
>
> end mouseUp
>
In this latter case you don't actually need to use the value function -
you could simply do
put field "AddTo" + tfKey into field "AddTo"
(see example below)
When you want the operator (such as + or * or -) to be evaluated -
that's when you need to use the "value" function.
> on mouseUp
> put 2 into tOther
> put field "inField" + tOther into tResult
> put "answer = " & tResult & cr after msg
>
> put "*" into tFX
> put value( field "inField" & tFX & tOther ) into tResult
> put "second answer = " & tResult & cr after msg
>
> end mouseUp
Note the entire expression is enclosed in the parentheses of value - i.e.
value ( field "inField" & tFX & tOther)
NOT value ( field "inField") & tFX & tOther which would be a
common mistake to make.
--
Alex Tweedly http://www.tweedly.net
--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.11.6 - Release Date: 06/05/2005
More information about the use-livecode
mailing list