1) In the Behavior section of the Inspector's data tab, there is a "select entire contents on entry" option that you can select for a field on your layout.
2) Many developers use an auto-enter calculation on number fields formatted to display data as a percent.
a simple calculation sometimes used is;
a more sophisticated option:
If ( Self > 1 ; self/100 ; self )
The second option allows you to enter 40% as either 0.40 or 40.
In both cases, you would clear the "do not replace existing values" check box.
Thanks for the tip for the "select all"!
Regarding the percentage, I thought using following script :
Set Variable [ $Number ; YourField ]
If [ $Number > 1 ]
Set Field [ YourField ; $Number / 100 ]
But this is usefull only if you can define dynamically "YourField" being the active field.
What do you think of this approach? Is it possible to define the active field?
Why use a script when you can produce the same result with an auto-enter calculation?
I'd write a scripted approach like this:
Set Variable [$Number ; value: Get ( activeFieldContents ) ]
SetVariable [$FieldRef ; value: Get ( ActiveFieldTableName ) & "::" & Get ( ActiveFieldName ) ]
If [ $Number > 1 ]
Set Field By Name [ $FieldRef ; $Number / 100 ]
This script won't work unless the cursor is still in the field at the point in time when the script executes.
Thanks a lot for your insight on this! Based on my readings, I thought that the scripting could be more easy and robust to implement but I understand that, regarding to you, the auto-enter calculation is at least as efficient.
I will thus go for the auto-enter calculation ;-)
Ok, small update in case others would have the same question as me later :
As suggested by PhilModJunk, the auto-enter calculation works very well and I used it for 80% of my "%" values.
Nevertheless, I will have to use the script for the last 20% of % fields because these were already having auto-enter calculation for which I also specified that no calculation should be done if the field is not empty.