Hi all; I've been working in Revolution for a while now and have been unable to find a command for a simple auto-calculate action. Currently, I have a "calculate" button that has to be manually pressed after entering in an integer (it displays the number divided by 3). I would like it to AUTOMATICALLY update the second field when someone enters an integer in the first field (also acceptable for it to calculate when the selection changes or they tab to the next field). I have tried a few things and been unable to come up with the solution:
on revSelectedObjectChanged
on revSelectionChanged
Any help would be appreciated!
Auto-calculate from Text Fields
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Re: Auto-calculate from Text Fields
Here you go.
The idea is to work with keyDown plus a regular expression to accept only digits, and another handler to handle the special case of backspace key
The idea is to work with keyDown plus a regular expression to accept only digits, and another handler to handle the special case of backspace key
Code: Select all
on KeyDown theKey
if matchText(theKey,"[0-9]") then
put thekey after me
put me/3 into fld "theResult"
else
beep
end if
end KeyDown
- Attachments
-
- TEST.zip
- (670 Bytes) Downloaded 238 times
Re: Auto-calculate from Text Fields
A more general solution, so that one can enter data in the middle of a number string and also not get waylaid if you enter a "Q", for example, is this in the field script:
Craig Newman
Code: Select all
on rawkeyUp var
if numToChar(var) is in ".0123456789" or var = 65288 then
put me/3 into fld "gg"
end if
end rawkeyUp
on keyDown var
if var is in ".0123456789" then pass keyDown
end keyDown