Auto Calculate Text Fields?
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Auto Calculate Text Fields?
Hi all,
Suppose I have 3 text fields. I put a number into fields 1 and 2. Without clicking anything, the sum of fields 1 and 2 automatically appear in field 3.
How does one achieve this?
Thanks,
Jon
Suppose I have 3 text fields. I put a number into fields 1 and 2. Without clicking anything, the sum of fields 1 and 2 automatically appear in field 3.
How does one achieve this?
Thanks,
Jon
-
- VIP Livecode Opensource Backer
- Posts: 9663
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Auto Calculate Text Fields?
Such a fun thing.
In the card script:
Craig newman
In the card script:
Code: Select all
on textChanged
put fld 1 + fld 2 into fld 3
end textChanged
-
- VIP Livecode Opensource Backer
- Posts: 9663
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Auto Calculate Text Fields?
Hi again.
Know that you can insert stuff like:
So that only the two fields of interest with valid text place their sums into that third field. That sort of thing, so that it actually works.
Craig
Know that you can insert stuff like:
Code: Select all
if the short name of the target is in variableContainingTheCorrectFieldNames and\
target is a number then...
Craig
Re: Auto Calculate Text Fields?
Hi Craig,
Nice! And super easy!
Thank you so much,
Jon
Nice! And super easy!
Thank you so much,
Jon
Re: Auto Calculate Text Fields?
I really like that second one Craig
I didn't see anyone checking if the field had a number or if it was empty though, and although you can add, subtract, and multiply with it, you really shouldn't ever divide by 0 if you can avoid it.
I didn't see anyone checking if the field had a number or if it was empty though, and although you can add, subtract, and multiply with it, you really shouldn't ever divide by 0 if you can avoid it.
Re: Auto Calculate Text Fields?
...and target is a number...?if the short name of the target is in variableContainingTheCorrectFieldNames and target is a number then...
Jamais, mes amis, jamais!
-
- VIP Livecode Opensource Backer
- Posts: 9663
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Auto Calculate Text Fields?
Monsieur Klaus
Pourquoi, mon petite chouchou?
Craig
Pourquoi, mon petite chouchou?
Craig
-
- VIP Livecode Opensource Backer
- Posts: 9663
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Auto Calculate Text Fields?
Bogs wrote:
Good point. Shows how important testing is. (Pseudo)
Craig
Code: Select all
a number or if it was empty t
Code: Select all
if the short name of the target is in varEtc... and\
(target is a number or target = "") then
-
- VIP Livecode Opensource Backer
- Posts: 9663
- Joined: Wed May 06, 2009 2:28 pm
- Location: New York, NY
Re: Auto Calculate Text Fields?
Klaus.
You, know, I thought that was it.
After all these years, you did not know about "target"? It goes back to HC v.1.
It really is a useful gadget. How did you live without it?
Craig
You, know, I thought that was it.
After all these years, you did not know about "target"? It goes back to HC v.1.
It really is a useful gadget. How did you live without it?
Craig
Re: Auto Calculate Text Fields?
Hi Craig,
Best
Klaus
I was not "X-Talk ready" when I received my first Mac LC with HC pre-installed in 1993, so I did not really understand HC or dived deeper into it.
Very fine, to be honest!
Best
Klaus
-
- VIP Livecode Opensource Backer
- Posts: 7237
- Joined: Sat Apr 08, 2006 8:31 pm
- Location: Minneapolis MN
- Contact:
Re: Auto Calculate Text Fields?
This brings up my pet peeve about the omission of "the" before property names. It can bite you if you aren't familiar with the entire dictionary.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com
HyperActive Software | http://www.hyperactivesw.com