|
|
What you are going to learn today:
Well, you're about to step into the wild, wacky, and completely out-of-control world of Pascal programming. But before you do so, you need to know the bare-bone basics of programming, and this is what this tutorial tries to do. This tutorial will introduce you to programming, what it is, how it works, and ways to make programming work for you, not you working for the program. What programming is all aboutWell, programming is about controlling the computer. That's why it's called programming. And how do you program? First, you use a language. Then you get a compiler, then Voila! You're a programmer! Pascal is an example of a programming language, and the only compilers on the market for Pascal come from Borland. Visit their website to find out how to get Turbo Pascal 7.0, if you don't have it yet. That's the compiler we'll be using throughout this webpage.The different parts of programmingNow, even before we even get into Pascal, let's ask the question you've all been waiting for: What is inside programming? Well, to answer this question, we'll try to tell you the typical parts of every programming language, whether it's Pascal, C++, or BASIC. Of course this list won't be complete, or accurate, but for the moment we'll be using this list to guide us on. Because this is pretty complex stuff, we recommend that you actually skip this entire list and go on to Day 2. Don't worry, everything will be explained in greater detail in the later tutorials.Variables - storing valuesAll programming language work on something called variables, which work the same way algebra does. Each variable has a name and contains a value. For example, a variable can be named a, and contains the value 2. Thus you can say that a + a = 4 ! Easy, no? Now, how do programming languages handle variables? Well, first, they put the variable they want to change in front, then the value it is to hold behind. Okay, so it seems weird, but its better than making a whole new concept for us to learn right? Constants - staying the sameEssentially, constants are what they are, constant. A constant just simply replaces something else, like how some publications replace certain words with asterisks when nessecary. To give an example, let's say that we replace every appearance of the word "lamb" with "head" to make the sentence "Mary had a little lamb" to become "Mary had a little head". Thus, you could say that the word "head" was a constant representing "lamb", with apologies to all lamb-lovers out there of course.Control Flow - changing directionsFor example, you can say, "Jump off the building if it is on fire, else continue typing your report." The statement above accomplishes something a list just can't do - change the direction. Procedures - sub-routinesWhen you need to do something again and again, or to process some information, the programming mechanism you use is called a procedure. A procedure is something like a fixed set of instructions which can be repeated again and again. For example, a procedure may state, "Get the number of customers in the room and get the appropiate number of chairs". Thus, this procedure can be used in a concert, or a party, or any one of those lavish social occasions people never really care to go to. That's how a procedure works.Functions - sub-routines which return valuesA function is just like a procedure, except that it returns a value. For instance, we may have a procedure that accepts two numbers, one representing the number of Godzillas there are in a room, the other representing the number of innocent bystanders passing by, and calculates the average number of screams every 5 seconds. This is called a function because it returns a value, which is the average number of screams.Comments - little notesThe final thing we have on our list are comments, which allow the programmer to add notes to his code. This makes the code easier for other people to read, and easier to change when debugging.How this all fits into PascalWell, you'll see very soon that Pascal implements all these little aspects of programming in its own way, and in its own style too. For now, go get a can of Coke from the fridge. You earned it. Cheers! Now, go on to Day 2, where you really start programming!email: tq97-11127@advanced.org |