Hi all

I am working on a bank reconciliation program and have a problem with data entry.
For a readln (real) statement, if a character is entered, it crashes the program. Is there a way to test the input data to keep it from crashing the program?

Also is there a way to run a control loop in the background so that I don’t have to enter a character to continue the loop with each entry. Initially I have I t set up so that I enter “c” from a menu to enter checks, and then for each additional entry I have to say “c” to repeat the loop for another entry. (In other words I would like to just be able to enter a loop and stay there until I am done entering the checks, and then just hit “x” or whatever to exit the loop, without having to restart the loop with each entry.)

Hi,

To prevent it from crashing put the conversion code in a try except block, if there will be a problem Delphi will throw an exception and you can handle it on the except part. To prevent typing c for new entries just let the user enter values one each other till he hits Enter alone (readln will return an empty string) or it writes "exit" then check entered string for exit or empty string.

Loren Soth

thanks loren, the try except did the trick!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.