Search
 
SCRIPT & CODE EXAMPLE
 

PASCAL

pascal error handling

Program TRY_EXCEPT_STATEMENT;
{$mode delphi}
uses crt,sysutils;

var
num:integer;
run:boolean;

begin 
    Writeln;
    run:=TRUE;
    
    While run do
    begin
        try    {if anything goes wrong in code, the program will move on to except}
           write('Enter an integer here please: ');
           readln(num);
           writeln('VALID INPUT');
           run := FALSE;
        except	{The program instead of crushing, does the following code} 
           writeln('WRONG INPUT - PLEASE TRY AGAIN');
           run := TRUE;
        end;
    end;
    
    Writeln;
end.

{ 
Program Description:
  Program gets input from the user and performs 
  a format validation check using the try-except 
  statement. The program will ask for input
  until the input entered is valid.
}
Comment

PREVIOUS NEXT
Code Example
Pascal :: pascal input format check 
Pascal :: pascal pause program for seconds 
Pascal :: pascal repetition 
Pascal :: print pascal triangle 
Pascal :: Pascal (gpc 20070904) sample 
Powershell :: takeown /f 
Powershell :: Windows 10 fbomber Batch Script 
Gdscript :: gdscript for loop 
Gdscript :: godot 3d slowly rotate towards object 
Clojure :: call function in clojure 
Lisp :: list contains lisp 
Assembly :: openssl public key der to pem 
Assembly :: windows detect system dark mode 
Assembly :: iterate over tqdm range 
Assembly :: how to check assembly compatibility X64 and x86 
Javascript :: jquery vslidation remove spaces from input 
Javascript :: jquery add disabled to button 
Javascript :: jquery run code after 5 seconds 
Javascript :: use jquery 
Javascript :: vimeo playback speed 
Javascript :: Basic JavaScript: Use Recursion to Create a Range of Numbers 
Javascript :: vuex-module-decorators rawError globally 
Javascript :: autoplay owl carousel 
Javascript :: how to get element by title js 
Javascript :: check ip json 
Javascript :: shadow elevation react native 
Javascript :: javascript capitalize string 
Javascript :: remove all options from select jquery 
Javascript :: swiper.js cdn 
Javascript :: angular go to route 
ADD CONTENT
Topic
Content
Source link
Name
9+9 =