I. DELPHI PASCAL IS BUT NOT THE DELPHI PASCALDelphi is a programming language having the character of Objects (Object Oriented Programming) means it is a program that has certain objects in its programming. In addition, Delphi is a program that is visual means to have a graphics display that is easily understood by beginners though (Graphical user Interface). With Delphi you can create programs with a charming view, Delphi can only work under System Microsoft Windows while for other systems such as Linux or Unix Delphi has a twin sister who could work on the system that is Kylix.Delphi syntax syntax in the adoption of the Pascal language, for it in the Delphi Basics tutorial, I will invite you into the past where computer programming while still using the system 16 BIT namely PASCAL language before you are taken to learn Delphi programming. If you can already PASCAL language you can skip this introduction about the language Pascal.Why do I bring you first to the language Pascal indirectly to Delphi?, By knowing the basics of the pascal language, you will be easy to learn Delphi programming for all that there is in pascals syntax similar to the Delphi language syntax, but the syntax in Delphi can not be adopted to pascal because that's the title I gave this introduction Delphi is Pascal but Pascal is not Delphi.II. Introduction to Language PascalInstallation PASCALOkay we are just on our first material that is the introduction of the pascal language easy for you to follow the next Delphi programming language. If you are having trouble finding Pascal language program version 5, you can download it here. (Download Pascal). But I warn you that this Pascal program should not be widely disseminated to the General again because I do not have a license to disseminate the program. And also you should not commercialize this program, because Pascal programs that I provide here only to study the program.Once you download exstract pascal.zip files using winrar (winrar Program Can be Downloaded from this site right pillar) or winzip. After that double click the file turbo.exe on the folder, then Turbo Pascal 5.5 program was able to run on, if you want a program a more complete Turbo Pascal follow these steps:Computer 1.Bila you have not installed winrar or winzip install the program, the program winrar you can download via the link on the right pillar of this site.2.Pindahkan pascal.zip file to Drive C: not in the folder again to be easy to call him on the Command Prompt.3.Bila Winrar installed, right click and select extract files pascal.zip to pascal.4.Jalankan Command Prompt from your windows, click start run and type command click ok then the command prompt will be displayed. Then type CD \ and type C: then the drive is currently active in the command prompt is drive C.5.Setelah the PASCAL type CD and press enter, so now you are on drive C: on the folder that you extract pascal it. Then Type Install and press enter. then TURBO PASCAL 5.5 installation process will take place. Just follow the installation instructions pascal is in the process of installation. The default installation folder pascal is TP.6.setelah pascal installation is complete exit from the program was first pascal, back to the command prompt. At the command prompt type anymore CD \ pascal then you will come back to the folder pascal, after being in the folder pascal extract some files that have a TP ARC to a folder, type the command DIR *. Previously ARC then all files that have the ARC will be displayed, record the name those files. There are several existing ARC files in this folder pascal namely: BGI.ARC, DEMOS.ARC, DOC.ARC, HELP.ARC, OOPDEMOS.ARC, TCALC.ARC, TOUR.ARC, TURBO3.ARC, and UTILS.ARC. These files can only extract the files in the folder UNPACK.COM pascal. mengekstract his way as follows:Create a folder in the directory TP accordance with the file names arc that will diextract example: You will mengekstract DEMOS.ARC files, create directories in the folder with the name TP DEMOS. Go to the folder TP - type CD \ TP then type MD DEMOS DEMOS then the folder with the name of the folder is created in TP. Having formed DEMOS folder now you switch back to the PASCAL folder by typing CD \ PASCAL, PASCAL in the folder type the following command unpacks DEMOS C: \ TP \ DEMOS and press Enter. So DEMOS.ARC file will extract into DEMOS folder inside the folder TP. Do the same on the other ARC file.
Views PASCAL version 5.5Starting PASCALIn the Pascal language you would not play with KEYBOARD MOUSE, so for the time being forget about the facilities which pampered by a WINDOWS GUI. because we go back to the 80s where the PASCAL programming language into a pavorite among SCIENTIEST time. The most basic keyboard button to access the PASCAL program is the key: alt, esc, ctrl, F1 - F12, ENTER, and arrow keys. so when one of the key is not functioning should just forget about it until you learn pascal replace your keyboard with the new.To start the pascal of windows you can double-click the file TURBO.EXE, whereas if through COMMAND PROMPT you can type the command and then press ENTER then TURBO PASCAL program will be loaded as shown above. Press the ESC key then the main program TURBO PASCAL will be displayed, from here KEYBOARD become your weapons to access the menus in the main program PASCAL. For more details about using the keyboard in pascal you can press the F1 key which will bring up the HELP facility in Pascal.To access the menu of pascal programs you use the ALT key followed by the first letter of a red, your example will access the File menu you can access it by pressing the ALT key and the letter F. Now press ALT E, then you are in editor mode, and PASCAL are ready to accept commands your program. As an introduction you try typing the following programs in PASCAL editor.(Program: Counting the Input from the keyboard and mathematical operations)(Create by: Komarudin_surya @ suryatekno)
uses Crt;varx, y, z: longint;again: char;namak: string [20];
beginagain: = 'y';
while (again = 'y') or (again = 'Y') do
begin
clrscr;
write ('Who's Your Name ..?'); ReadLn (namak);
Writeln;
write ('Hello', namak, 'Just you');
Writeln ('input value of x, y and z');
Writeln ('on these mathematical operations.');
Writeln;
Writeln ('mathematical operation X ^ 2 y ^ 2 z =.....');
write ('input value of x. .='); ReadLn (x);
write ('input value y. .='); ReadLn (y);
write ('input value of z. .='); ReadLn (z);
Writeln;
Writeln ('value operation x ^ 2 y ^ 2 z is:', x * xy * yz);
Writeln;
write ('Want to count again what is not (y / t),', namak, '');
readLn (again);
end;end.After you type the source code is save the file with testprog.pas name, then press the CTRL-F9 to see the results of the program that you type them.Who's Your Name ...? _Masukanlah Any Name, say the name you input is Bejo, then the next sentence will be shown as below:Who's Your Name ...? BejoBejo Hallo, Try your input indigo x, y, and zmathematical operations below.Mathematical operation x ^ 2 y ^ 2 = z is ......input value of x. .= _Now the program asks you to enter the operating value for x then y and z, after which the program will display the results of mathematical operations and asked again to you, whether to calculate again or not, when you enter the letter t, the program will be stopped while if you enter y letter the program will be repeated again.Who's Your Name ...? BejoBejo Hallo, Try your input indigo x, y, and zmathematical operations below.Mathematical operation x ^ 2 y ^ 2 = z is ......input value of x. .= 5input value y. .= 5input value of z. .= 5operating value of x ^ 2 y ^ 2 z is: 55Want to count again what is not (y / t), Bejo? _From the introduction above example program, you can see in this simple program, there are several attributes, variables, as well as some statements. Now let us describe a simple program based on the groups.(Program: Input from the keyboard andCompute mathematical operations)(Create by: Komarudin_surya @ suryatekno)In part this is a COMMENT that was not processed by the program, this comment section is required for the purposes of documentation for the program to know the goals and objectives and a time when we will add or change the program so we can quickly find out the location of the program we need to add or altered. To provide comments in pascals is given a sign of (and) or (* and *), so anything that is written in brackets will not be processed by the program.uses Crt;This is a UNIT command, the Unit has several procedures and types. UNIT in Pascal must be included to enable procedures to be programmed. While the procedure can be shaped in the Pascal procedures defined or made by the user or procedure that has been provided by Pascal. Procedures defined by the user must be declared first.The units in PASCAL 5.5 There are seven standard units, seven units are stored in a file called TURBO.TPL. The units are:1.UNIT System - This unit is a Turbo Pascal runtime that supports all the processes needed at runtime (program execution). You will see an error message like this "Runtime Error" when you're wrong in manipulating the system can be saved. This unit automatically added by Pascal even though you do not include her when her Compile.2.UNIT CRT - This unit is used for programs in manipulating the screen, in this case can be TEXT manipulation, cursor, etc. CODE EXTENDED KEYBOARD.3.UNIT Printer - As the name implies, the unit is of course used in the program associated with the printer, eg we will print a program to the printer, the unit must be used to activate the printer. The printer can support only the printer type LPT and COM, while a USB printer type can not be accessed because at that time there is no USB printer type, unless the printer DRIVER for DOS provides the possibility of a USB printer can be used by this PASCAL 5.5.Examples of programs that use the printer unit:(* Printing Printer Program, Note Dlm Pascal 5.0 and above must be added the word LST *)Uses Printers;BeginWriteln (LST, 'I'm trying to Printer. ");Writeln (LST, 'Create By: Suryatekno © 2008');Writeln (LST ,'============================');End.4.UNIT DOS - This unit is used when you want to activate the procedures that exist in DOS like DosVersion, GetTime, SetTime, DiskSize, DiskFree, Call, Dir, Path, Copy and so on.Examples of programs that use DOS units:(* Program see what version of DOS and the rest of the Disk,Create By: Suryatekno *)Uses DOS, CRT;var size: longint;Beginsize: = DiskFree (0);ClrScr;Writeln ('DOS version you use is: MS-DOS', DosVersion);Writeln ('Time Capacity of your hard drive:', size, 'Bytes');Writeln;Writeln ('Press any key to exit');ReadLn;End.5.UNIT Graph - This unit is used to display graphics such as Table, Chart Statistics and so on. This unit is usually used when we want to display a graph as in MS-EXCEL. Can also be used to create animations, games and so forth.(The program displays the Bar Graph,Create By: Suryatekno 2008)Uses Graph;varDriver, Model: integer;I: integer;BeginDriver: = VGA;Model: = VGAHi;InitGraph (Driver, Model, '');Line (20,25,20,155);Line (20,155,200,155);Randomize;for I: = 0 to 4 doBar3D (30 I * 35, 154-random (100), 55 I * 35,154,15, TopOn);Writeln;Writeln ('Press Any Key to Exit');ReadLn;End.6.UNIT Turbo3 - This unit is used in pascal pascal version 3.0 while 4.0 and above for these units are retired or not enabled. Usefulness is when you upgrade from version 3.0 to 4.0 pascals or 5.0, an exercise we now do not we use this unit only.7.UNIT Graph3 - This unit is used to convert graphics created by pascal version 3.0 for use by pascal 4.0 and above, the same as the unit Pascal3 this unit did not we use this in our practice because we use the PASCAL version 5.5 more sophisticated and complete.For more details about these units please go to the folder that exist on Directory DOC TP. Or if you are a creative person and not easily satisfied please you look for references from other sites or media, is highly recommended and I held up my thumb when you do this.Now we proceed on the discussion of an introductory program that you created the first time.varx, y, z: longint;again: char;namak: string [20];In this section called a VARIABLE, All programming languages require variables to determine the type or types of data used by the programmer. In the example program is our recognition that inform the PASCAL type or types of variables that we use for variable x, y, and z bertype longint, variable again bertype namak bertype char and a variable length character string with as many as 20 strings.1. DECLARATION OF VARIABLE (VARIABLE Declaration)Variable declaration is a declaration that its value is certain, in other words, the Declaration of this type can not be changed again or constant. In the example program above, the declaration of variables for x, y and z-type longint (integers from -2147483648 to 2147483648), then in the program, the only type of data can be entered are manifold. In the example above, if you enter a value other than that type, suppose you enter the numbers in question A on the input values .= x. Then the program will error, Well for there are no error messages in the program, then the program must be added a command line type logic so when users enter the values of x, y and z apart from that type will be issued a warning that tells the user to enter a value for x, y and z can only be entered by a type variable.Please you add on the command line program testprog.pas above, so users do not wrong in entering the data type specified!.2. DECLARATION Constant (Constant Declaration)Same as variable declarations, constant declarations are also fixed (constant), the difference is when the variable declaration we just declare the type of data that must be done, whereas in our constant declarations directly mention its value. Declaration of constants does not use a colon (:) as in variable declarations, but use the equal sign (=).Examples of programs that use constant declarations
(Program: Use of constant declaration
Design By: suryatekno © 2008)
uses crt;
const
name = 'Amir';
nip = 'A3110';
salary = 1000000;
overtime = 50 000;begin
clrscr;
Writeln ('Employee Name:', name);
Writeln ('N I P:', nip);
Writeln ('Salary:', salary);
Writeln ('Money Overtime:', overtime);
Writeln ('--------------------- ');
Writeln ('Total Wages:', overtime pay);
Writeln;
Writeln ('Press ENTER to exit');
readLn;end.
Views PASCAL version 5.5Starting PASCALIn the Pascal language you would not play with KEYBOARD MOUSE, so for the time being forget about the facilities which pampered by a WINDOWS GUI. because we go back to the 80s where the PASCAL programming language into a pavorite among SCIENTIEST time. The most basic keyboard button to access the PASCAL program is the key: alt, esc, ctrl, F1 - F12, ENTER, and arrow keys. so when one of the key is not functioning should just forget about it until you learn pascal replace your keyboard with the new.To start the pascal of windows you can double-click the file TURBO.EXE, whereas if through COMMAND PROMPT you can type the command and then press ENTER then TURBO PASCAL program will be loaded as shown above. Press the ESC key then the main program TURBO PASCAL will be displayed, from here KEYBOARD become your weapons to access the menus in the main program PASCAL. For more details about using the keyboard in pascal you can press the F1 key which will bring up the HELP facility in Pascal.To access the menu of pascal programs you use the ALT key followed by the first letter of a red, your example will access the File menu you can access it by pressing the ALT key and the letter F. Now press ALT E, then you are in editor mode, and PASCAL are ready to accept commands your program. As an introduction you try typing the following programs in PASCAL editor.(Program: Counting the Input from the keyboard and mathematical operations)(Create by: Komarudin_surya @ suryatekno)
uses Crt;varx, y, z: longint;again: char;namak: string [20];
beginagain: = 'y';
while (again = 'y') or (again = 'Y') do
begin
clrscr;
write ('Who's Your Name ..?'); ReadLn (namak);
Writeln;
write ('Hello', namak, 'Just you');
Writeln ('input value of x, y and z');
Writeln ('on these mathematical operations.');
Writeln;
Writeln ('mathematical operation X ^ 2 y ^ 2 z =.....');
write ('input value of x. .='); ReadLn (x);
write ('input value y. .='); ReadLn (y);
write ('input value of z. .='); ReadLn (z);
Writeln;
Writeln ('value operation x ^ 2 y ^ 2 z is:', x * xy * yz);
Writeln;
write ('Want to count again what is not (y / t),', namak, '');
readLn (again);
end;end.After you type the source code is save the file with testprog.pas name, then press the CTRL-F9 to see the results of the program that you type them.Who's Your Name ...? _Masukanlah Any Name, say the name you input is Bejo, then the next sentence will be shown as below:Who's Your Name ...? BejoBejo Hallo, Try your input indigo x, y, and zmathematical operations below.Mathematical operation x ^ 2 y ^ 2 = z is ......input value of x. .= _Now the program asks you to enter the operating value for x then y and z, after which the program will display the results of mathematical operations and asked again to you, whether to calculate again or not, when you enter the letter t, the program will be stopped while if you enter y letter the program will be repeated again.Who's Your Name ...? BejoBejo Hallo, Try your input indigo x, y, and zmathematical operations below.Mathematical operation x ^ 2 y ^ 2 = z is ......input value of x. .= 5input value y. .= 5input value of z. .= 5operating value of x ^ 2 y ^ 2 z is: 55Want to count again what is not (y / t), Bejo? _From the introduction above example program, you can see in this simple program, there are several attributes, variables, as well as some statements. Now let us describe a simple program based on the groups.(Program: Input from the keyboard andCompute mathematical operations)(Create by: Komarudin_surya @ suryatekno)In part this is a COMMENT that was not processed by the program, this comment section is required for the purposes of documentation for the program to know the goals and objectives and a time when we will add or change the program so we can quickly find out the location of the program we need to add or altered. To provide comments in pascals is given a sign of (and) or (* and *), so anything that is written in brackets will not be processed by the program.uses Crt;This is a UNIT command, the Unit has several procedures and types. UNIT in Pascal must be included to enable procedures to be programmed. While the procedure can be shaped in the Pascal procedures defined or made by the user or procedure that has been provided by Pascal. Procedures defined by the user must be declared first.The units in PASCAL 5.5 There are seven standard units, seven units are stored in a file called TURBO.TPL. The units are:1.UNIT System - This unit is a Turbo Pascal runtime that supports all the processes needed at runtime (program execution). You will see an error message like this "Runtime Error" when you're wrong in manipulating the system can be saved. This unit automatically added by Pascal even though you do not include her when her Compile.2.UNIT CRT - This unit is used for programs in manipulating the screen, in this case can be TEXT manipulation, cursor, etc. CODE EXTENDED KEYBOARD.3.UNIT Printer - As the name implies, the unit is of course used in the program associated with the printer, eg we will print a program to the printer, the unit must be used to activate the printer. The printer can support only the printer type LPT and COM, while a USB printer type can not be accessed because at that time there is no USB printer type, unless the printer DRIVER for DOS provides the possibility of a USB printer can be used by this PASCAL 5.5.Examples of programs that use the printer unit:(* Printing Printer Program, Note Dlm Pascal 5.0 and above must be added the word LST *)Uses Printers;BeginWriteln (LST, 'I'm trying to Printer. ");Writeln (LST, 'Create By: Suryatekno © 2008');Writeln (LST ,'============================');End.4.UNIT DOS - This unit is used when you want to activate the procedures that exist in DOS like DosVersion, GetTime, SetTime, DiskSize, DiskFree, Call, Dir, Path, Copy and so on.Examples of programs that use DOS units:(* Program see what version of DOS and the rest of the Disk,Create By: Suryatekno *)Uses DOS, CRT;var size: longint;Beginsize: = DiskFree (0);ClrScr;Writeln ('DOS version you use is: MS-DOS', DosVersion);Writeln ('Time Capacity of your hard drive:', size, 'Bytes');Writeln;Writeln ('Press any key to exit');ReadLn;End.5.UNIT Graph - This unit is used to display graphics such as Table, Chart Statistics and so on. This unit is usually used when we want to display a graph as in MS-EXCEL. Can also be used to create animations, games and so forth.(The program displays the Bar Graph,Create By: Suryatekno 2008)Uses Graph;varDriver, Model: integer;I: integer;BeginDriver: = VGA;Model: = VGAHi;InitGraph (Driver, Model, '');Line (20,25,20,155);Line (20,155,200,155);Randomize;for I: = 0 to 4 doBar3D (30 I * 35, 154-random (100), 55 I * 35,154,15, TopOn);Writeln;Writeln ('Press Any Key to Exit');ReadLn;End.6.UNIT Turbo3 - This unit is used in pascal pascal version 3.0 while 4.0 and above for these units are retired or not enabled. Usefulness is when you upgrade from version 3.0 to 4.0 pascals or 5.0, an exercise we now do not we use this unit only.7.UNIT Graph3 - This unit is used to convert graphics created by pascal version 3.0 for use by pascal 4.0 and above, the same as the unit Pascal3 this unit did not we use this in our practice because we use the PASCAL version 5.5 more sophisticated and complete.For more details about these units please go to the folder that exist on Directory DOC TP. Or if you are a creative person and not easily satisfied please you look for references from other sites or media, is highly recommended and I held up my thumb when you do this.Now we proceed on the discussion of an introductory program that you created the first time.varx, y, z: longint;again: char;namak: string [20];In this section called a VARIABLE, All programming languages require variables to determine the type or types of data used by the programmer. In the example program is our recognition that inform the PASCAL type or types of variables that we use for variable x, y, and z bertype longint, variable again bertype namak bertype char and a variable length character string with as many as 20 strings.1. DECLARATION OF VARIABLE (VARIABLE Declaration)Variable declaration is a declaration that its value is certain, in other words, the Declaration of this type can not be changed again or constant. In the example program above, the declaration of variables for x, y and z-type longint (integers from -2147483648 to 2147483648), then in the program, the only type of data can be entered are manifold. In the example above, if you enter a value other than that type, suppose you enter the numbers in question A on the input values .= x. Then the program will error, Well for there are no error messages in the program, then the program must be added a command line type logic so when users enter the values of x, y and z apart from that type will be issued a warning that tells the user to enter a value for x, y and z can only be entered by a type variable.Please you add on the command line program testprog.pas above, so users do not wrong in entering the data type specified!.2. DECLARATION Constant (Constant Declaration)Same as variable declarations, constant declarations are also fixed (constant), the difference is when the variable declaration we just declare the type of data that must be done, whereas in our constant declarations directly mention its value. Declaration of constants does not use a colon (:) as in variable declarations, but use the equal sign (=).Examples of programs that use constant declarations
(Program: Use of constant declaration
Design By: suryatekno © 2008)
uses crt;
const
name = 'Amir';
nip = 'A3110';
salary = 1000000;
overtime = 50 000;begin
clrscr;
Writeln ('Employee Name:', name);
Writeln ('N I P:', nip);
Writeln ('Salary:', salary);
Writeln ('Money Overtime:', overtime);
Writeln ('--------------------- ');
Writeln ('Total Wages:', overtime pay);
Writeln;
Writeln ('Press ENTER to exit');
readLn;end.
Tidak ada komentar:
Posting Komentar