Difference between revisions of "Tutorial:Getting Started"
m (*sight* another few typo's)
m (more typo's removed and other wording applied, should be all for now (unless i made typo's myself again).)
|Line 38:||Line 38:|
On the left
On the left side the close Button (the little green square). The title the current can be used to move the window around double click maximize or restore the window (of coursethe size has to be to see effect, just keep reading). The one at the upper right indicates the number of the editor window. The green arrow next to used to maximize and restore the window.
On the right side
On the right side a checkered area with two which represents the scrollbar for the editor textworks like the Amiga (But it is not proportionaljust a blue square represent the current position as visible at the lower border). The border the for horizontal . Between the two scrollbars in the lower corner is the size gadgetand drag to resize the window.
the left side the current , <code>1:1</code> the .
In the editor you can
In the editor you can blinking cursorwhere you can .
very first program, of course "Hello World"
|Line 49:||Line 49:|
it difficult to find the right quotation mark, especially on UAE (on a keyboard seems Alt+Ä does work, for it should be the single quotation mark directly on the keyboard). If you the right keyit should show the quotation mark in turquoise color, if is yellow then it the wrong . Notice that behind the last <code>end</code> there should be a .
Before we can compile and run
Before we can compile and run , we have to save it. To the filecan use Menu entry or press F2 . save as dialog will open. navigate type the path into the edit field for <code>Name</code> and press Enter key e.g. <code>work:</code>contents of the Drawer/Device will be shown in the area underneath. Use Mouse or + Enter to navigate where you want to save your file(<code>../</code> means parent directory and is always at the end of the list). e.g. Work:Sources in this example as can in the lower part of the dialog window .
In the <code>Name</code> edit field the currently selected file name is written
In the <code>Name</code> edit fieldthe currently selected file name is writtenthe name and type <code>helloworld.pas</code> and enter or press <code>OK</code> .
Now we our program, press F9 or choose Compile from the Compile Menu. Depending on your computer (especially Hardrive speed) it will some time to compile (a real Amiga around 30 , NG Amigashould only some seconds ).
FP-IDE should tell you "Compile successfully: Press any key", it found some . green window opens with the error messages. Try to check the source carefully for typing errors (also the colors , which can give you a hint about wrong ). The compiler should tell you the position of errornavigate to the error and press enter to jump to the error . you have no idea maybe you want to ask on Forum or IRC whats wrong.
run our program press Ctrl-F9 or choose Run from the Run Menu. The Editor window closes very fast and opens again. The Output of the program can be seen in the second window.
This Tutorial should not be a complete
managed to write, compile and run your first Program on Amiga using and FP-IDE. Now you can extend your program a more meaningful program. Do not forget to save your progress (with F2 or Menu) compile (with F9) and run it (Ctrl-F9).
This Tutorial should not be a complete tutorial . If you are not Pascal you should try to find one of the many and try some on your Amiga (CRT and GRAPH units are not available so jump over parts using graphics for now). If you found a good Pascal tutorial you should announce the link to it here for other people.
Revision as of 20:50, 11 February 2017
This page is available in german
Check the installation guide for your platform:
- download the archive for your specified platform, unpack it where you want to have it, add the FreePascal: assign and the path to your user-startup (or use package installer for AROS)
When using the commandline compiler, you can use your favorite editor (such as VIM, Annotate, etc) and compile via command line compiler. In this Tutorial we will mainly use the FP-IDE but here is a short introduction how to use the command line compiler.
- open a shell
fpc -land press enter. Free Pascal will return with some information about the installed Free Pascal compiler. If you get this feedback returned from the compiler that means that the compiler is installed correctly (and working).
- to compile a Pascal source file, just type
fpc sourcefile.pas. Usually Pascal sources have the extension .pas but (other) Pascal compilers sometimes also uses the extensions .pp and/or .p
- to compile a Lazarus project compile the .lpr file
fpc lazarusproject.lpr. In case of a Delphi compatible project, the extension used is .dpr
The Free Pascal IDE is ANSI based editor with embedded pascal compiler like the well known Turbo Pascal on MS-DOS. It uses the FreeVision package which is a open source package comparable to TurboVision used in Turbo Pascal. It needs a screen with at least 8 colors, although it works with 4 color screen as well but in that case things look a little bit strange and some text may not be easy to read.
To start the IDE, navigate to the
PP folder and find the
Double click the
FP-IDE Icon to start the Editor. The editor will then present you the FP-IDE Desktop. At the same time the IDE will also open a Shell window where the output (if any) of your program will appear when it is run from within the editor. So, it would be good to arrange the windows in such a way that you are able to see both at the same time.
In the window, at the top, you can see the the menu line. It's an old DOS based program. The menu that the IDE uses is a bit different than your typical Amiga menu. You can use the mouse to navigate to the menu's and press the left mouse button to open and select menu entries. Or you can use the keyboard and press Left Alt-Key and one of the red chars short-cut of the Menu entries to open the Menu, select an Entry again with the red marked char or use cursor keys and enter key to select a Menu Entry. The middle part of the IDE leaves room for our editor window(s) that we will use later on in this tutorial. The lower hotkey line (status bar) shows some often used shortcuts such as Open and Compile, which are very useful
Since we would like to create a new file, we navigate to the
File Menu and select
An editor should now open (you can open multiple editor windows, so go ahead and play around to get yourself familiar with how these windows work).
On the upper left side you can find the close Button (the little green square). The window title which displays the current filename can be used to move the window around or you can double click on this title bar to maximize or restore the window (of course, the size of the windows has to be changed first in order to see it's effect, just keep reading). The number one at the upper right of the edit window indicates the number of the editor window. The green arrow directly next to the number can also be used to maximize and restore the window.
On the right side there is a checkered area with two arrows which represents the scrollbar for the editor text. The scrollbar works like those that can be found/used on the Amiga (But it is not proportional, just a blue square that represent the current position as visible at the lower border). The border at the bottom of the window has a similar scrollbar but is used for horizontal scrolling. Between the two scrollbars in the lower right corner is the size gadget. Click and drag in order to resize the window.
At the lower left side you can find the current cursor position, showing
1:1 in the above picture.
In the editor window itself you can find a blinking cursor, where you can start typing your code.
Let's start with typing our very first program, of course this would be the well-known "Hello World"
program helloworld; begin writeln('Hello World'); end.
On some configurations it is sometimes difficult to find the right key that produces the correct quotation mark, especially on UAE (on a German keyboard seems Alt+Ä does work, for English it should be the single quotation mark directly on the keyboard). If you were able to determine the the right key, it should show the quotation mark in turquoise color, if the quote character is displayed in yellow then this indicates it is the wrong quote character. Notice that behind the last
end there should be a dot (as every Pascal Program is required to end with a dot).
Before we can compile and run our program, we have to save it. To save the file, you can either use Menu entry (using the mouse and/or or keyboard) or press F2 directly. In case the editor window was not saved before, a save as dialog window will open. In order to navigate through directories, type the path into the edit field for
Name and press the Enter key e.g.
work:. The contents of the Drawer/Device will be shown in the area underneath. Use the Mouse or cursor-keys + Enter to navigate where you want to save your file. As is common for certain platforms, (
../ means parent directory and this entry is always located at the end of the list). e.g. Work:Sources in this example as can be seen in the lower part of the dialog window in the above picture.
Name edit field, the currently selected file name is written. Delete the existing name and type
helloworld.pas and then either hit your enter key or press the
OK button (by either using the mouse or navigating to this button using the tab-key).
Now that we have saved our program, we are now able to compile it. In order to do so, press F9 or choose Compile from the Compile Menu. Depending on your computer (especially Hardrive speed) it will take some time to compile your source-code (On a real Amiga this takes around 30 secs, on NG Amiga's this should take only some seconds or even milliseconds). In case FP-IDE was able to compile your program correctly, its progress dialog should tell you "Compile successfully: Press any key". If the FP-IDE was unable to compiler your source-code, then it found some error(s). In case the latter, a green window opens with the error messages. Try to check the source carefully for typing errors (also note the different colors in which your code is being displayed , which can give you a hint about having used the wrong character(s) or having used uncompleted keywords). The compiler should tell you the exact (cursor) position of error. Inside the error window you can navigate to the error and press enter on the displayed error line in order to directly jump to the error in your source editor window. In case you have no idea what the error message is trying to tell you then maybe you want to ask us on Forum or IRC whats wrong. (in which case, always try to supply the code you are trying to compile together with the error message that you've received from the compiler).
In order to run our program you can either press Ctrl-F9 or choose Run from the Run Menu. The Editor window closes very fast and then opens again. The Output of the program can be seen in the second window.
You've managed to write, compile and run your first Program on Amiga using Free Pascal and FP-IDE. Now you can extend your program to create a more meaningful program. Do not forget to save your progress (with F2 or Menu) compile (with F9) and run it (Ctrl-F9).
This Tutorial should not be looked at as being a complete tutorial for Pascal illiterates. If you are not familiar with the Pascal programming language, you really should try to find one of the many available Pascal tutorials and try some of the accompanied examples on your Amiga (CRT and GRAPH units are not available so jump over parts using graphics for now). If you found a good Pascal tutorial you should announce the link to it here for other people.