Okay, now here's something interesting to talk about. Programming!
I'll be covering the very basics, just you know.. Installing all that good stuff that you'll need as well as writing your very first, infamous HelloWorld program :D
So first of all, here's a short list of what you'll need.
Click the links and install away!
If, for some reason, your not a wizard and can't seem to either find the correct download or you're having trouble installing any of the above, smash me an email. Or use Google. Google's great. Exceptional. Astronimical. Seriously, it works wonder. It's the answer to all life's problems.
Now, my wizards, when you go to install MinGW and the Free Pascal Compiler, make sure you tick ✓ALL the boxes you come across in each installation screen.
No ✓, no program. Simple. First thing's first. Open Notepad ++.
1. Enter the following code.
1. Enter the following code.
program HelloWorld;
procedure main();
begin
WriteLn('Hello World.');
end;
begin
main();
end.Indentation is important. Use Tab to get it looking good and stuff.
A few things you'll need to know before we go further.
program is exactly that. It's telling the compiler that you want to create a program.
HelloWorld is what's known as the identifier. You can call it whatever you want, but in this case it's HelloWorld.
The semicolons (;) are used to finish a line of code. It's like using a full stop when you've finished a sentence, only it's.. well. a semicolon.
A procedure is a set of instructions. The second line of code states that you are making a new procedure, and you are calling it 'main.'
The begin and end is used to start and finish your instructions. Your instructions, of course, go in the middle. In this case, the instructions are that you want to write (WriteLn) 'Hello World.' to the console.
That's the procedure done.
Now, instead of having to write 'WriteLn('Hello World.');' every time you wish to print 'Hello World,' you can simply write the name of the procedure and the program will then execute the instructions within.
Notice how the end at the bottom has the full stop? That's telling the compiler that that's the end of the program. Between that end and begin statement is where you call your procedures.Save. Make sure you save it as a Pascal (.pas) file, otherwise you'll die.
Now you're going to want to compile your program. Open MinGW and type cd, followed by the directory you saved your Pascal file in.
For example:
cd /c/Documents/Code/Pascal on Windows or
cd ~/Documents/Code/Pascal on MacOS or Linux
The 'cd' prompt changes the directory the console is currently in.
Type 'ls' to display a list of files and folders that are in your current directory.
Once you've navigated to the directory you saved your HelloWorld program in, type:
fpc -S2 HelloWorld.pas
Any problems, just email me. It makes me feel special :D
You should get some jumble text. That means it worked and you're now God.
If you got 35976 errors, you lost The Game.
Fix it, or again, email me :D
Run your program using ./HelloWorld
And voila!
Want to lose your virginity? Show chicks this awesome lil' program and you'll lose it in know time :D

0 comments:
Post a Comment