Using script in a number field to default the field to zero
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller
Using script in a number field to default the field to zero
Part A I have a button on a card that manipulates numbers input by a user in four fields . When the button is engaged
I would like the script in the number field to check if the the field is blank if it is I would like
to enter a zero in that field. Part B. Does this kind of code go into the script for the field? If
it does not go in the number field script what kind of stuff does and can you run it from a button.
I would like the script in the number field to check if the the field is blank if it is I would like
to enter a zero in that field. Part B. Does this kind of code go into the script for the field? If
it does not go in the number field script what kind of stuff does and can you run it from a button.
Re: Using script in a number field to default the field to z
You can make a check in the field script when a user edits or leaves the field (see "closeField" and "exitField"). But you will have to verify in the button script as well, in case nobody made an entry at all (or at least set a default value on openCard for instance).
So check in the button script,
So check in the button script,
Code: Select all
put field "numberfield" into tNum
if tNum is empty then --also maybe check "is not a number" or other validation
put 0 into tNum
put 0 into field "numberfield"
end if
--do stuff with tNumRe: Using script in a number field to default the field to z
Hi Mike,
A & B:
you can use a "closefield" handler in the field script:
Best
Klaus
A & B:
you can use a "closefield" handler in the field script:
Code: Select all
on closefield
if me = EMPTY then
put 0 into me
end if
end closefieldKlaus
Re: Using script in a number field to default the field to z
Thanks both pieces of code work good with one small change using "" instead of the word empty. I don"t know why
but this seems to work better on repeated tries
but this seems to work better on repeated tries
Re: Using script in a number field to default the field to z
Not sure but I guess "" and empty are the same thing. Anyway the problem i'm having now is if you
put a couple of blank spaces in the field the code will not change the field to 0 but instead leaves it blank
any ideas?
put a couple of blank spaces in the field the code will not change the field to 0 but instead leaves it blank
any ideas?
Re: Using script in a number field to default the field to z
As I mentioned, also check if the contents "is a number" or not.
You could also check if it "is an integer" or not.
You could also check if it "is an integer" or not.