*******************************
*Pascal Tutorial Guide ver 1.8* 
*******************************

REQUIREMENTS:

Basic knowledge on how to use your pc.
Basic knowledge of System Engineer.
Basic knowledge of the Operative System 

Permission to redistribute it exactly, how you got it but not able to modify it. Not for commercial purposes.
We're not responsible for any case of loss or damage to the world. This Guide belongs to the "Srx-56 Company."

SUGGESTION: A High-Level Language from today is not optimized. In order to optimize it you agree to learn asm(assembler), if you're going to publish such important programs towards future. Check my page to learn more about the optimization discussion. INSTALLATION Basic 1. -What's pascal? 2. -Section I -Instructions -Logical Dictionary Abreviations -Logical Operations -Source Codes -Tricks -Optimization Hints Support Author's Note Credits -------------- |INSTALLATION| -------------- NOTE: Tp7.0, Download the compiler & the help files. http://www.cgcinc.freeserve.co.uk/pascal/ Unzip in C:\ Root. C:\tp\bin Turbo Pascal 7.0 paste it to "My Desktop." Basic -------------------- |1. -What's pascal?| -------------------- Blaise Pascal invented the first digital calculator and the second mechanical calculator. Schickard was the first one who invented a mechanical calculator in 1623. The name was given for this compiler. Pascal died at the age of 39 in intense pain after a malignant growth in his stomach spread to the brain. Blaise Pascal's Characteristics: ... a man of slight build with a loud voice and somewhat overbearing manner. ... he lived most of his adult life in great pain. He had always been in delicate health, suffering even in his youth from migraine ... ... precocious, stubbornly persevering, a perfectionist, pugnacious to the point of bullying ruthlessness yet seeking to be meek and humble ... Assessment: At once a physicist, a mathematician, an eloquent publicist in the Provinciales ... Pascal was embarrassed by the very abundance of his talents. It has been suggested that it was his too concrete turn of mind that prevented his discovering the infinitesimal calculus, and in some of the Provinciales the mysterious relations of human beings with God are treated as if they were a geometrical problem. But these considerations are far outweighed by the profit that he drew from the multiplicity of his gifts, his religious writings are rigorous because of his scientific training... So, the name of this compiler is pascal. It's a High-Level Language compiler with some great optimizations. NOTE: http://www-groups.dcs.st-and.ac.uk/~history/Mathematicians/Pascal.html This is the link where I got it from. Research for yourself the Pascal History and Pascal Technology to obtain for more information. A great salute to Blaise Pascal! --------------- |2. -Section I| --------------- ************** *Instructions* ************** What's a variable? It's a type of symbol which can change value. What's a constant? It's a type of symbol which can't change value. What's integer? It's a type of symbol defined in normal numbers. What's a string? It's a type of symbol defined in letters. Allows a maximum character of 255. Ex: 'Hello!'. What's real? It's a type of symbol defined in decimal numbers. What's the instruction "Program"? The name of the program. What's the instruction "Uses"? The main types of instruction it's going to be use. What's the instruction "crt(Cathode ray tube)"? Defines the use of colors, mathematic calculations, mouse, etc. What's the instruction "Begin"? To begin a process of the program. What's the instruction "clrscr"? It clears the screen from junk view. What's the instruction "Write"? Output in the same line. What's the insruction "WriteLn"? Output in another line. What's the instruction "Read"? Read and input. What's the instruction "ReadLn"? Read and input in another line. What's ln? Line. What're the instructions "Readkey & Repeat Until Keypressed"? Read the whole process if uses "uses." What's the instruction "end"? The end of the program. What's ;? Declare a type of instruction. What's {}? It's a commentary. What's the instruction "IF"? Condition. What's the instruction "THEN"? After condition second choice. What's the instruction "ELSE"? Use after then giving the opposite meaning. What's the instruction "FOR"? cycle the value. What's the instructon "Case"? Defines in parts the processes. What's the instruction "While"? An chronological interrupton. What's the instruction "Repeat Until"? It'll repeat the selected process. What's the instruction "GOTO"? Define a label, the label's code'll be executed in the chosen process. What's the instruction "Procedure"? It saves the selected procedure. ******************** *Logical Dictionary* ******************** What's an initialize data? It's a type of data that contains the execute code. What's an uninitializes data? It's a type of data that contains the non-execute code. What's Bloated code? Code not use. What's optimization? The best quality as possible. What're normal numbers? Are numbers ranging from 0 to 100... and from 0 to -100... + Positive - Negative What're decimal numbers? Are numbers that are divided. Ex: 0.1, 1.3, etc. What're procedures? Are steps to form a struture data. What're global variables? Are variables that can be use in any part of the program. What're local variables? Are variables that can be used only in a procedure. NOTE: This is only showing you that this can be done in Turbo Pascal. It's not right to do this, since it'll only contain more bloated code. Abreviations ------------ ------------ Opt: Output Ipt: Input Clrscr: ClearScreen Var: Variable/s ln: Line Crt: Cathode ray tube ******************** *Logical Operations* ******************** + : Plus - : Minus * : Multiplication div : A type of division that contains the coscient. Syntax " 10 div 5 = 2 " / : Divides decimal numbers. mod : A type of division that contains the residue. Syntax " 11 mod 5 = 1 " ":=" : Symbol to define something. Syntax " example:= value; " [] : Declares a especific value. ":" : Declares a section. ************** *Source Codes* ************** You can use NOTEPAD, or whatever compatible text. At the end save it as .pas and put it in the folder c:\tp\bin\ Program name; { Name of the program } begin { begin process } writeln('Hello World!'); { outputting in another line } writeln('Greetings!'); write('See ya!'); { outputting same line } end. { main end } RUN > RUN, COMPILE > COMPILE NOTE: tp/bin/nameoftheprogram.exe/.com ; it's suggested that you install it in the C:\ Root Directory. START > RUN > type: "cmd" ENTER > cd c:\tp\bin\ ENTER nameoftheprogram.exe/.com ENTER Some programs are able to be run without the C:\> Command Prompt, otherwise use the cmd. NOTE: ln gives a space at the next line. Ex: writeln('Hello!'); write('Good Bye'); View Hello! Good Bye PROGRAM String_; VAR Nombre : String[30]; { Allows 30 characters inside the variable } BEGIN Name := 'Ernesto Chávez'; WriteLn (Name[5]); { Visualize the 5th character } END. Program plus_operation; uses crt; { using crt } var a,b,c: integer; { defining integer } begin clrscr; { clearscreen } write('insert two numbers for the plus operation'); read(a,b); { inputting a and b } c:= a+b; { c equal a and b } write(' = ', c ); { input final value syntax = ' ', symbol } readkey; { reading the process uses as a base } end. Program number; uses crt; var x: integer; begin clrscr; write('insert normal numbers'); IF x > 0 { condition bigger than 0 } THEN { second choice } write('it is a positive number') { at this time we don't use ; for the second choice } ELSE { opposite } write('it is a negative number'); repeat until keypressed; { same as readkey } end. Program cycle; uses crt; var a,b: integer; begin clrscr; write('insert a number from 1 to 100'); readln(a); for a:= 1 to 100 do { cycling a, now a is = 1 to 100 } b:=1; { b = normal numbers } a:=b; { a = b } write('the number you had chosen is', a ); readkey; end. Optimized NOTE: Check these programs compiled, you'll note with this method you'll save space. Because the words 'insert a number' is not a variable then it's define like a constant. For the program to run faster define first the constants and then define the variables. Program minus_operation; Ues crt; { defining constant } Const Output = 'insert two numbers for the minus operation '; { we make a character space at this symbol ' ouputting } Equal = '='; Var a,b,c:real; { decimal numbers } Begin clrscr; Write(Output); Read(a,b); { note a & b cannot be constants } c:= a-b; Write(Equal ,c); { we give a space to the comma before } Readkey; End. Program Constants_Defines_as_Variables; Const Initialize = 'This is an inicialize data '; Not_Inicialize = 'This is not an inicialize data '; Initialize_Number : integer = 20; { The constant number define as integer } Initialize_Letters : string = 'Hello!'; { define as string } Var Number_Not_Inicialize: integer; Letters_Not_Inicialize: string; Begin Writeln(Inicialize, Initialize_Number); Writeln(Not_Inicialize, Number_Not_Inicialize); Writeln(Inicialize, Initialize_Letters); Write(Not_Inicialize, Letters_Not_Inicialize); End. Program Case_; Uses crt; Const Opt = 'Insert normal numbers from 1 to 5: '; { menu 1 to 5 } first = 1; second = 2; third = 3; fourth = 4; fith = 5; one = 'The number was 1: '; two = 'The number was 2: '; three = 'The number was 3: '; four = 'The number was 4: '; five = 'The number was 5: '; Msg = 'The number wasn't in the indicated range: '; Var Number :integer; Begin clrscr; Write(Opt); read(Number); Case Number OF { case it's going to be use for menu } first: Write(one); second: Write(two); third: Write(three); fourth: Write(four); fith: Write(five); ELSE Write(Msg); End; { ends all the processes because there're more than one } Readkey; End. Program while_; Uses crt; Const Insert = 'insert two numbers number: '; Msg = 'I was receiving classes while the teacher was giving me some math. '; Opt = ''; var a,b: integer; begin clrscr; Write(Insert); Read(a,b); While a = b do {while a & b = Msg} Write(Opt , a); Write(Msg); Readkey; End. NOTE: Before running this program, be sure that you had saved anything because you'll have to use the CTRL+ALT+DELETE. Program Repeat_Until; Const Msg ='Hello!'; var c: integer; Begin repeat write(Msg); { we'll repeat this } UNTIL c = 1 ; { s = infinite times } End. Program Goto_; Const Print = 'This line it's going to be written'; PrintNo = 'This line it's not going to be written'; Jump = 'the label was chosen'; Label MyLabel; { defining the label } Begin Writeln(Print); { the process Print is the selected label } GOTO MyLabel; { go to label "MyLabel" } Write(PrintNo); { this'll be bloated code } MyLabel: { selected label } Write(Jump); End. PROGRAM Procedure_; CONST Msg = 'Turbo Pascal Program'; Msg2 = 'Example of procedures'; PROCEDURE Title; { Name of the procedure } BEGIN WriteLn (Msg); { structure procedure } END; BEGIN { beginning next procedure } WriteLn (Msg2); Title; { calling the procedure title } WriteLn; { calling the procedure WriteLn to give space } Title; { calling again the same procedure } END. ******** *Tricks* ******** NOTE: This program is bloated code but the funny thing it can be run without the Command Prompt, and you can type anything it will end until you type ENTER. It takes less space than crt. Program Output_; Const Output = 'Hello World!'; Begin Write(Output); readln; end. PROGRAM Variables; VAR Hello : String; { global variable } PROCEDURE test; VAR Bye : String; BEGIN Bye := 'Bye, have a nice day!'; WriteLn (Bye); { local variable } END; BEGIN { In this section the variable bye is not recognize } Hello := 'Hello!, welcome to the program'; WriteLn (Hello); test; END. Program Sum_; Const Opt1 ='Input number 1:'; Opt2 ='Input number 2:'; var a,b,c: integer; begin write(Opt1); readln(a); write(Opt2); readln(b); c:=a+b; write(c); readln; end. ******************** *Optimization Hints* ******************** -Structure well your program in order. Ex: Program ex; Const Msg1 ='Hello!'; { constants here are define in the order that will be use in the program } Msg2 ='Bye!'; Begin Writeln(Msg1); write(Msg2); end. -Use constants when you're going to output. Ex: Program ex; Const Msg1 ='Hello!'; Msg2 ='Bye!'; Begin Writeln(Msg1); { instead of writeln('message'); we use the constants to save space } write(Msg2); end. -Use your instructions wisely, don't waste time in writing a longer one. -Each instruction has it's own function. -Don't use write, writeln, read and readln for waste. Use it formerly. -Don't use crt and readkey for every program because it cause bloated code to appear. -Remember a string it's only used especially for the defines of characters. --------- |Support| --------- NOTE: This is only for pascal resource, but in the forum if find out more, fine. http://www.greatmindz.tk/ NOTE: register in the forum & participate, if so wish. http://programmersheaven.com/ http://pascalprogramming.schoolreference.com/ --------------- |Author's Note| --------------- I won't be supporting this project anymore, I will like to see someone finding all the tricks and the completion of this tutorial, it seems that's not very useful to publish important programs. If anyone wants to complete it feel free to contact me, but in the publish you must add me in the credits. The forum will be available for help, so feel free to ask. The official version it's the one without a version, the ones with a great grammar and more example codes. --------- |Credits| --------- Thanks to Victor Saliba for his site. Thanks to Devil Panther for his tutorial. Thanks to Jeremy Gordon for his site with tutorial. Homepage: http://www.geocities.com/fine010010/ Contacts: ripperfromlightpath@gmail.com, char_amuro@hotmail.com, fine010010@yahoo.com & skype: char amuro NOTE: If you're going to add me in skype, you must first send an email. Copyright, All Rights Reserved to the Srx-56 Company.