•
•
•
•
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 402,593 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 2,317 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: 4356 | Replies: 7
![]() |
Hi.
First of all, I'd like to apologize for I really do not know where to post this thread to. :lol: I know Pascal is out but apparently I have got to pick up this language in order to finish my project.
What I'd like to ask is whether Pascal offers exception handling. I'd like to read an integer but I've to consider the chances of users keying in a non-integer value. I've checked different sites which offer free online tutorial but to no avail. Please help. Thank you.
First of all, I'd like to apologize for I really do not know where to post this thread to. :lol: I know Pascal is out but apparently I have got to pick up this language in order to finish my project.
What I'd like to ask is whether Pascal offers exception handling. I'd like to read an integer but I've to consider the chances of users keying in a non-integer value. I've checked different sites which offer free online tutorial but to no avail. Please help. Thank you.
Greetings.
A thousand apologies.
I was browsing through some old threads and I accidentally bump into my own old thread. :cheesy:
I had eventually gave up on exception handling because I still cannot figure out the way. However, if you know, I'd like to learn it. Thanks a lot.
That was a small program that I got to write using Pascal as a starter.
I'd like to handle the exception where the prompt for an input from the user goes. I only want an integer here.
Any idea?
A thousand apologies.
I was browsing through some old threads and I accidentally bump into my own old thread. :cheesy:
I had eventually gave up on exception handling because I still cannot figure out the way. However, if you know, I'd like to learn it. Thanks a lot.
•
•
•
•
Program FactorialCalculator;
uses crt;
var input : integer;
function calculate(num:integer):integer;
begin
if ((num = 0) or (num = 1)) then
calculate := 1
else
calculate := calculate(num-1) * num;
end;
begin
writeln;
writeln;
writeln('*** FACTORIAL CALCULATOR ***');
writeln('Enter integer: ');
readln(input);
writeln('The factorial of ',input,' is ',calculate(input));
end.
That was a small program that I got to write using Pascal as a starter.
I'd like to handle the exception where the prompt for an input from the user goes. I only want an integer here.
Any idea?
Hello,
Unfortunately, my Pascal things are in another city. Grr. What happens if you input a letter? Does the program substitute the ASCII value of the letter instead? Hmm. I am wondering if you should accept a string, and then convert it to numeric. I have to see if that function is even available in Pascal.
Wow, I am out of date here.
Christian
Unfortunately, my Pascal things are in another city. Grr. What happens if you input a letter? Does the program substitute the ASCII value of the letter instead? Hmm. I am wondering if you should accept a string, and then convert it to numeric. I have to see if that function is even available in Pascal.
Wow, I am out of date here.
Christian
Greetings.
Alright. It's ok. I'm just glad that after so long, there is actually a reply from someone.
I'm in my office right now ( Industrial Training
). I'll check with my pascal compiler once I get home later in the night.
Thanks anyway, Christian.
Alright. It's ok. I'm just glad that after so long, there is actually a reply from someone.
I'm in my office right now ( Industrial Training
). I'll check with my pascal compiler once I get home later in the night.•
•
•
•
What happens if you input a letter? Does the program substitute the ASCII value of the letter instead?
•
•
Join Date: Jan 2005
Posts: 31
Reputation:
Rep Power: 4
Solved Threads: 0
program FactorialCalculator;
{$APPTYPE CONSOLE}
uses
SysUtils;
var
input : string;
value : Integer;
function calculate( num : integer ) : integer;
begin
if ( ( num = 0 ) or ( num = 1 ) ) then
calculate := 1
else
calculate := calculate( num - 1 ) * num;
end;
begin
writeln;
writeln;
writeln( '*** FACTORIAL CALCULATOR ***' );
repeat
write( 'Enter integer: ' );
readln( input );
until TryStrToInt( input, value );
writeln( 'The factorial of ', input, ' is ', calculate( value ) );
end.•
•
Join Date: Nov 2004
Location: Netherlands
Posts: 5,698
Reputation:
Rep Power: 18
Solved Threads: 195
Whether you get exception handling or not depends on the flavour of Pascal you're working with.
Delphi (which is Pascal with a nice IDE and stuff) for example has a comprehensive exception mechanism (though it might not have been available in the very early versions, I don't have those here to check).
Other dialects may have duplicated this over time (Borland being the de-facto standard for Pascal in lue of an official standards body).
Delphi (which is Pascal with a nice IDE and stuff) for example has a comprehensive exception mechanism (though it might not have been available in the very early versions, I don't have those here to check).
Other dialects may have duplicated this over time (Borland being the de-facto standard for Pascal in lue of an official standards body).
![]() |
•
•
•
•
•
•
•
•
DaniWeb Pascal and Delphi Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- Pseudo-Pascal Question: Need Help!! (Pascal and Delphi)
Other Threads in the Pascal and Delphi Forum
- Previous Thread: Dev Pascal help!
- Next Thread: ask



Linear Mode