Board index » delphi » Help Required Please
Paul
![]() Delphi Developer |
Sat, 14 Dec 2002 03:00:00 GMT
Help Required PleaseQuote----- Original Message ----- |
Paul
![]() Delphi Developer |
Sat, 14 Dec 2002 03:00:00 GMT
Help Required PleaseQuote----- Original Message ----- |
Mike Gerschefsk
![]() Delphi Developer |
Sat, 14 Dec 2002 03:00:00 GMT
Re:Help Required PleaseI think what you want to use is a for loop... Or while...! try this: {Repeat Loop} repeat writeln{'Enter rm #'); readln(roomnr); if (roomnr < 1) or (roomnr > 12) then writeln ('Room Number Incorrect :'); until (roomnr > 1) or (roomnr < 12); {For Loop} for i := 1 to 10 do begin writeln{'Enter rm #'); readln(roomnr); if (roomnr < 1) or (roomnr > 12) then writeln ('Room Number Incorrect :') else end; inc(i,1); end; I think that should do it...??? QuotePaul wrote: |
Mike Copela
![]() Delphi Developer |
Sat, 14 Dec 2002 03:00:00 GMT
Re:Help Required PleaseQuote> I think what you want to use is a for loop... Or while...! (which doesn't have a finite number of iterations stated/planned). A While loop would work, but I feel the Repeat loop is best here. Now, your Repeat loop isn't correct - for his problem. Your loop will exit (terminate) with value in the range 2..11, which isn't how the problem is presented. The loop should terminate when any value 1-12 is entered. Also, using a compound termination condition isn't required, and the more that's added, the greater chance there is for a coding or logic error (I think it happened to you...). So, I would do it otherwise, and one simple way is: until RoomNr in [1..12] which states clearly what the termination condition is...as well as verifies the problem's logic, I feel. Lastly, (added) code to handle pathological data entry (non-numerics) would be good, too: it would be unfortunate for such a simple program to abort just because some idiot didn't key in numerics digits, wouldn't you agree? 8<}} Quote> Also, try to advoid using capitals and lowercase through out your code, this Pascal programmer will "move to C/C++ or Java"? I hardly think it's necessary to impose the harsh restrictions of another language on someone who's clearly learning to acquire the basics of programming...and there are a great many people in the world who _don't_ use a case-sensitive programming language! |
Mike Gerschefsk
![]() Delphi Developer |
Sun, 15 Dec 2002 03:00:00 GMT
Re:Help Required PleaseAccording to the problem it wants a value greater then one, and a value less then 12, not a value greater then or equal to one, nor a value less then or equal to 12. Also, no, I didn't bother even testing my code down there (Yes, I know, shame on me). Just as well, I do think the majority of people that learn pascal go on to learn C/C++ and so on. Besides, mixing cases is bad form anyways (ie Roomnr, roomnr). Also, no worries here, his question was well answered in news://news.uswest.net/comp.lang.pascal.borland -Mike "Pascal... From the creators of Pascal's Triangle" QuoteMike Copeland wrote: |
Sebastian Koppeh
![]() Delphi Developer |
Mon, 16 Dec 2002 03:00:00 GMT
Re:Help Required PleaseHi, QuoteMike Copeland wrote: stupid features of these languages. Considering the C look-alike contest currently being held among language designers, however, I don't expect it to vanish from the face of the planet anytime soon... - Sebastian |
Paul
![]() Delphi Developer |
Tue, 17 Dec 2002 03:00:00 GMT
Re:Help Required PleaseMany thanks for all the replies, helped me sort the thing out. Assignment now handed in...... awaiting result. Thanks again to all that replied. Paul. QuotePaul <sp...@s2new.freeserve.co.uk> wrote in message Quote> ----- Original Message ----- |
1. HELP REQUIRED PLEASE !!!!!!!!
3. Locate, LocateNext - help required please
5. TTcpServer please help me oh, PLEASE PLEASE PLEASE HELP ME
6. Please Help external sorting routines required
7. Please Help Me - SQL Required Files
8. Help urgently required please.
9. Ex Paradox requires Delphi Help PLEASE !
10. SQL editor with additional features required - please help.