•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Pascal and Delphi section within the Software Development category of DaniWeb, a massive community of 423,539 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 4,227 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Pascal and Delphi advertiser: Programming Forums
Views: 1803 | Replies: 22
![]() |
•
•
Join Date: Oct 2007
Location: Cherry Hill, NJ
Posts: 1,876
Reputation:
Rep Power: 11
Solved Threads: 193
•
•
Join Date: Oct 2007
Location: Cherry Hill, NJ
Posts: 1,876
Reputation:
Rep Power: 11
Solved Threads: 193
It keeps the program from crashing on bad input.
Read up on exceptions. The first two links here on google are very good.
Whenever you use a function like strToInt or strToFloat (conversion routines), or any kind of I/O routine, put your cursor on the name of the procedure and press F1, then read what exceptions may be raised when the conversion or I/O or whatever fails. Then use a try..except block so to catch the exception and do something more intelligent than simply terminate the program.
You never know what a user will type when given the chance, so it is always best to make sure the program can continue even if the user types something really idiotic. The example I gave you catches bad input by complaining with a message dialog, focusing the input box, and exiting the routine to wait for the user to try again.
Hope this helps.
Read up on exceptions. The first two links here on google are very good.
Whenever you use a function like strToInt or strToFloat (conversion routines), or any kind of I/O routine, put your cursor on the name of the procedure and press F1, then read what exceptions may be raised when the conversion or I/O or whatever fails. Then use a try..except block so to catch the exception and do something more intelligent than simply terminate the program.
You never know what a user will type when given the chance, so it is always best to make sure the program can continue even if the user types something really idiotic. The example I gave you catches bad input by complaining with a message dialog, focusing the input box, and exiting the routine to wait for the user to try again.
Hope this helps.
Last edited by Duoas : Feb 13th, 2008 at 4:03 pm.
![]() |
•
•
•
•
•
•
•
•
DaniWeb Pascal and Delphi Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- Previous Thread: how to connect SQL database through delphi?
- Next Thread: How do you change file owner in Delphi?



Linear Mode