User Name Password Register
DaniWeb IT Discussion Community
All
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
Reply
Join Date: Oct 2007
Location: Cherry Hill, NJ
Posts: 1,876
Reputation: Duoas is a splendid one to behold Duoas is a splendid one to behold Duoas is a splendid one to behold Duoas is a splendid one to behold Duoas is a splendid one to behold Duoas is a splendid one to behold Duoas is a splendid one to behold 
Rep Power: 11
Solved Threads: 193
Featured Poster
Duoas's Avatar
Duoas Duoas is offline Offline
Posting Virtuoso

Re: Help With Delphi Petrol Pump Logic.

  #21  
Feb 13th, 2008
Try entering a price per litre of "abc" and pressing the button. Without the try...except block, your program would crash.
Reply With Quote  
Join Date: Dec 2007
Posts: 21
Reputation: Lynxus is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
Lynxus Lynxus is offline Offline
Newbie Poster

Re: Help With Delphi Petrol Pump Logic.

  #22  
Feb 13th, 2008
Okay but I was just interested in knowing what that bit of code does.
Reply With Quote  
Join Date: Oct 2007
Location: Cherry Hill, NJ
Posts: 1,876
Reputation: Duoas is a splendid one to behold Duoas is a splendid one to behold Duoas is a splendid one to behold Duoas is a splendid one to behold Duoas is a splendid one to behold Duoas is a splendid one to behold Duoas is a splendid one to behold 
Rep Power: 11
Solved Threads: 193
Featured Poster
Duoas's Avatar
Duoas Duoas is offline Offline
Posting Virtuoso

Re: Help With Delphi Petrol Pump Logic.

  #23  
Feb 13th, 2008
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.
Last edited by Duoas : Feb 13th, 2008 at 4:03 pm.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb Pascal and Delphi Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Other Threads in the Pascal and Delphi Forum

All times are GMT -4. The time now is 5:38 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC