Tech Tip: Use the "better" command to preclude user errors
PRODUCT: 4D | VERSION: 13.3 | PLATFORM: Mac & Win
Published On: June 11, 2013
When developing an application it is easy to create conditions for end users to make avoidable mistakes. For example using the 4D Request command when CONFIRM is the "better" choice.
In the following example a simple "yes" or "no" answer is needed from the user and the Request command is used....
$Request_T:=Request("Are you sure you want to delete these files? -- Yes or No") If( $Request_T = "N@" ) // Keep the files Else // Delete the files End if |
If the user makes the easy mistake of hitting any first key other than "n" the files will be deleted, intentional or not.
When all is needed is a boolean response from a user it is "better" to use the 4D command that restricts the users response to a "Yes" or "No," the CONFIRM command, and testing the OK variable for the "confirm" response to the question. This does not eliminate the users chance of making a mistake, but reduces the chances greatly.