| ★ wanayoo — archive 1999 http://www.codeforge.com/tutorials/AdaTutorial.html | Nouvelle recherche | Portail wanayoo |
|
Ada 95 "Hello World" Tutorial |
|
To use IDE you must first install properly GNAT binaries, utilities and setup environment variables.
First, you must create a new project to work. For this, press You'll get the dialog very similar to next one.
Enter the name of project, project's author, description and comments. Note, that for project will be created directory in 'Project Root' with the 'Name', appended by suffix "-prj". In given case it will be '/home/alx/gnat_test-prj/'. Press the 'OK' button, and target dialog will be appear.
Here you can enter the name of first target in this project - stay it default. Directory layout can be useful, if you want to separate source, include and object files. But for GNAT you need to disable check button "Use directory layout". If you enable it - jumps to editor from errors in log window would be unavailable. Don't forget to change the type of this target - it might be 'Ada executable'. Press 'OK' button and you'll get your project window.
Now, here is only one target in project. Move cursor selection to this target and press
The file, which you want to add, does not exist - press 'New File' button and enter the name of it: gnat_test.adb Note, that name of main source file might be equal to target name, but with extension '.adb' - ADa Body file. Add yet one source file - 'gnat_package.adb'. It will be example of package using. Now, using the Headers files will be appear in special folder, because you don't need to compile specs; they are compiled when they are used. After this work the tree of your project is looks like this:
Select all sources and headers, using Ctrl. And drag and drop them (using Mouse button 2) to Working Files Desktop. Example is shown at the next picture.
At this moment the working copies and RCS locks for these files will be created.
Edit main file gnat_test.adb by double clicking on it in Working Descktop:
This file is putting line "Hello from Gnat_test !", then call a procedure 'Hello' from package 'Gnat_package', and puts the goodby text. The package file might look like this:
In this package only one procedure, which is puts yet one line. For this package the spec file might be this:
Save files in all editors, move the cursor to target and press
If there is some errors in source files - in log window will be 'red' (errors) and/or 'cyan' (warning) lines: double click on them will popup corresponding source on error line. And now double click on target - it will be executed, with output in project log:
Now let's create a yet one new target using the Move cursor to new target and add source file with main procedure (gnat_test2.adb) using the
There is call to procedure 'Hello' from package 'gnat_package' - for proper compiling of this example we need to add this package in dependency tree of new target. To do so - move cursor selection to gnat_package.adb in dependency tree and simply Ctrl-Shift Drag'n'Drop it (using mouse button 2) to new target, like this:
The file 'gnat_package.adb' will be appear in dependency of 'gnat_test2'. And now, lets make this target using Drag'n'Drop. To do it - move this target from dependency tree to 'Make drop site' as shown below:
To execute new target also double click on it.
|
Copyright © Code Forge, Inc. 1997-99. All rights reserved.
Last modified: Thursday, 30-Sep-1999 02:12:37 MDT