Page 2 of 2
Re: math
Posted: Wed Sep 05, 2018 6:58 pm
by Klaus
Hm, you could try this:
Code: Select all
...
put fld "input" into age -- contains the age in years
put 67 - age into Y
## To see if it is really anumber
ANSWER Y
put max(1,Y) into x
...
Running out of ideas now...
Re: math
Posted: Wed Sep 05, 2018 8:21 pm
by avivchen64
I now got to a conclusion that the problem is the subtracting the age from 67,
somebody has an alternate way to do that?
Klaus, tried what you suggested, no luck.
Re: math
Posted: Wed Sep 05, 2018 8:35 pm
by Klaus
What exactly does "no luck" mean?
Did you see the answer dialog?
If yes, what did it tell you?
I created the same szenario, field "input", field "output" and a button with this script:
Code: Select all
on mouseUp
put fld "input" into age -- contains the age in years
put max(1,67-age) into x -- avoid division by zero
put 1000000 into v -- the target amount
put 0.1 into r -- the interest rate 10% of one = 0.1
put yearlyAmount(x,r,v) into fld "output"
end mouseUp
function yearlyAmount x,r,v
put v/((((1+r)^x)-1)/r) into ann
return format("%.2f",ann) -- cash format = two digits
end yearlyAmount
I entered a number into fld "input" and got a valid result in fld "output".
So the script is definitvely OK and the problem must be somewhere else!
Re: math
Posted: Wed Sep 05, 2018 8:37 pm
by SparkOut
I think the value in the variable named age must nor be valid. ("age" isn't a reserved word, is it? I don't think so.)
Try
Code: Select all
put field "input" into tAge
if tAge is a number then
put 67 - tAge into Y
put max (1,Y) into X
else
answer "tAge is not a valid number and contains" && tAge
end if
I am going to guess that field "input" LOOKS like it contains a number, but it also has a return character after it. That would make it a string which can't be subtracted from a number. Try clearing the field, set its "tabOnReturn" property true and that should prevent the issue if this is the correct guess. Above all, data entry validation is at the heart of it.
Re: math
Posted: Wed Sep 05, 2018 8:53 pm
by Klaus
I already suggested this, and according to Aviv, everything is OK!?
Re: math
Posted: Wed Sep 05, 2018 10:56 pm
by SparkOut
I don't see where he's confirmed that the value in the field is not taking extra empty lines / cr through to the variable value. He just said "no luck" but I still suspect that the issue is with a blank line/ cr in the input field .
Re: math
Posted: Thu Sep 06, 2018 10:01 am
by MaxV
Hi can't understand the forumal, the first form was:
The second form is:
Is this the formula?
Re: math
Posted: Thu Sep 06, 2018 10:01 am
by Klaus
SparkOut wrote: Wed Sep 05, 2018 10:56 pmI don't see where he's confirmed that the value in the field is not taking extra empty lines / cr through to the variable value. He just said "no luck" but I still suspect that the issue is with a blank line/ cr in the input field.
So do I, but finally I decided to believe him, must be my good education...

Re: math
Posted: Thu Sep 06, 2018 10:02 am
by Klaus
Buongiorno Max,
MaxV wrote: Thu Sep 06, 2018 10:01 am
Hi can't understand the forumal, the first form was:

The second form is:

Is this the formula?
I think Hermann is the only person who really knows.
Best
Klaus (Claudio Maggiore)
Re: math
Posted: Thu Sep 06, 2018 3:24 pm
by bogs
I'm no -hh (by any stretch of the imagination), but let us see if we can help you out breaking down the formula by explaining percentages as digits since the 10% is all that really changed for the 2 formulas, so I'll refer you to
this page which makes it pretty easy and painless to understand.
Here is the quote pertaining to your question though -
Explanation:
To convert from percents to decimals, you divide the percent by 100, which gives you decimal equivalent of the percent.
So, if you have 10%, and you want to express that as a decimal (which is what you need to do the calculation), you do this -
Go ahead, pull out the calculator, and enter it just that way, and you'll see it pop up .1, and if you reverse it, you'll get 10 back again.
Re: math
Posted: Thu Sep 06, 2018 3:48 pm
by avivchen64
Hi all,
thank you for your help, you're the best!
I finally figured this out, couldn't do it without you!
hope you all having a great day <3 , if not hope it'll get better ASAP.
thanks again,
Aviv
Re: math
Posted: Thu Sep 06, 2018 5:49 pm
by capellan
Hi Avivchen,
Which was the error? A comma? A return? Parentheses?
Thanks in advance!
Al
Re: math
Posted: Thu Sep 06, 2018 9:04 pm
by avivchen64
actually there were 2 problems, the first one was the subtraction problem,
I couldn't do it, the max(67-age) didn't work for me... the code with tAge worked for me.
the second prob was the fact that failed tries I did still were written in the input field.
have a great day!
Aviv