issue111:tutoriel2
Différences
Ci-dessous, les différences entre deux révisions de la page.
Prochaine révision | Révision précédente | ||
issue111:tutoriel2 [2016/07/31 14:27] – créée auntiee | issue111:tutoriel2 [2016/08/23 18:51] (Version actuelle) – andre_domenech | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
- | Many PC programmers started with one of Borland’s products, back in the day. Both Turbo Pascal and Turbo C ran on the MS-DOS operating system, and had excellent integrated development environments comprised not only of the compiler itself, but also a nice editor. To the point, they also contained a system of text-based widgets (buttons, radios, editing areas, menus…) called Turbo Vision that was not only used to build the IDE itself, but was also at the disposition of programmers for their own applications. | + | **Many PC programmers started with one of Borland’s products, back in the day. Both Turbo Pascal and Turbo C ran on the MS-DOS operating system, and had excellent integrated development environments comprised not only of the compiler itself, but also a nice editor. To the point, they also contained a system of text-based widgets (buttons, radios, editing areas, menus…) called Turbo Vision that was not only used to build the IDE itself, but was also at the disposition of programmers for their own applications. |
- | For simplicity and for elegance, it has not yet been surpassed as a text-oriented human interface. This is not only my own very honest opinion, but also that of some others - as seen on the Internet. So, it must be true. It was with interest that I discovered the existence of Free Pascal (www.freepascal.org), | + | For simplicity and for elegance, it has not yet been surpassed as a text-oriented human interface. This is not only my own very honest opinion, but also that of some others - as seen on the Internet. So, it must be true. It was with interest that I discovered the existence of Free Pascal (www.freepascal.org), |
- | In this series of articles, I will be building | + | Il y a pas mal de temps, beaucoup de programmeurs sur PC ont commencé avec l'un des produits Borland. Turbo-Pascal |
- | Why? | + | Pour la simplicité et l' |
+ | |||
+ | **In this series of articles, I will be building a text-based application with Free Pascal, using its text-based interface for user interaction. This will be combined with other, more modern, technologies such as database access using SQL, and Web access with HTTP. The final aim of the project is to demonstrate how Pascal can be used to build a modern application, | ||
+ | |||
+ | Dans cette série d' | ||
+ | |||
+ | **Why? | ||
Before delving into the technical intricacies of setting up the Free Pascal and Free Vision combination, | Before delving into the technical intricacies of setting up the Free Pascal and Free Vision combination, | ||
Ligne 11: | Ligne 17: | ||
Meanwhile, the program using Free Vision is a compiled, executable binary that does not need to contend with all the quirks of a graphical interface or HTTP server. These are available, but the programmers do not need to waste CPU or RAM on them unless they are actually useful to what they are doing. | Meanwhile, the program using Free Vision is a compiled, executable binary that does not need to contend with all the quirks of a graphical interface or HTTP server. These are available, but the programmers do not need to waste CPU or RAM on them unless they are actually useful to what they are doing. | ||
- | A second, equally valid, answer may be: “for old times’ sake.” Pascal is also a nice, clear and structured programing language that can help us get into good habits - habits that JavaScript is not known for nurturing, just to give a quick example. | + | A second, equally valid, answer may be: “for old times’ sake.” Pascal is also a nice, clear and structured programing language that can help us get into good habits - habits that JavaScript is not known for nurturing, just to give a quick example.** |
- | Installation | + | Pourquoi ? |
+ | |||
+ | Avant de plonger dans la complexité technique du paramétrage d'une combinaison de FreePascal et de Free Vision, il serait peut-être judicieux de répondre à cette simple question : pourquoi cela vaudrait-il le coup pour moi de passer du temps sur cette technologie ? Après tout, il y a pléthore d' | ||
+ | |||
+ | En attendant, le programme utilisant Free Vision est un binaire exécutable compilé qui n'a pas besoin d' | ||
+ | |||
+ | Une seconde réponse, tout aussi valable, pourrait être : « En souvenir du passé ». Pascal est aussi un beau et clair langage de programmation structurée, | ||
+ | |||
+ | **Installation | ||
Free Pascal is installable using standard tools (apt, synaptic…) from Ubuntu 16.04’s repositories, | Free Pascal is installable using standard tools (apt, synaptic…) from Ubuntu 16.04’s repositories, | ||
Ligne 20: | Ligne 34: | ||
Running the install script as root will allow us to install the lot, choosing between either /usr or /usr/local as a starting point for our files. The decompression process is fast and hassle-free. Once done, we have the appropriate PATH variable set in our system, and can proceed with creating a directory for our source files, and opening it within a terminal. Something along the lines: | Running the install script as root will allow us to install the lot, choosing between either /usr or /usr/local as a starting point for our files. The decompression process is fast and hassle-free. Once done, we have the appropriate PATH variable set in our system, and can proceed with creating a directory for our source files, and opening it within a terminal. Something along the lines: | ||
+ | |||
+ | mkdir Desktop/ | ||
+ | |||
+ | cd Desktop/ | ||
+ | |||
+ | fp** | ||
+ | |||
+ | Installation | ||
+ | |||
+ | Free Pascal s' | ||
+ | |||
+ | Juste pour voir s'il y a des différences avec la version originale du développeur, | ||
+ | |||
+ | Le lancement du script d' | ||
mkdir Desktop/ | mkdir Desktop/ | ||
Ligne 27: | Ligne 55: | ||
fp | fp | ||
- | There were no detectable differences with the version from the repositories. The final command launches the integrated Pascal IDE (Integrated Development Environment), | + | **There were no detectable differences with the version from the repositories. The final command launches the integrated Pascal IDE (Integrated Development Environment), |
A configuration file is created for the environment within this directory. At this point, we can immediately begin programming. However, if we need to use units such as Crt, we will need to direct the IDE to use the appropriate unit directory. This is a step the installer does not seem to take care of. Simply choose Options > Directories in the main menu, and add the following two lines. If you have installed in /usr instead of in /usr/local, do the appropriate modifications: | A configuration file is created for the environment within this directory. At this point, we can immediately begin programming. However, if we need to use units such as Crt, we will need to direct the IDE to use the appropriate unit directory. This is a step the installer does not seem to take care of. Simply choose Options > Directories in the main menu, and add the following two lines. If you have installed in /usr instead of in /usr/local, do the appropriate modifications: | ||
Ligne 35: | Ligne 63: | ||
/ | / | ||
- | The first line is to include the unit directory itself, while the second also includes any subdirectories within the search path. | + | The first line is to include the unit directory itself, while the second also includes any subdirectories within the search path.** |
- | Compiling a console program | + | Il n'y a pas de différence visible avec la version des dépôts. La dernière commande lance l'IDE (Integrated Development Environment - Environnement de Développement Intégré) intégré à Pascal, qui rappellera des souvenirs aux programmeurs en Turbo Pascal. Certains d' |
+ | |||
+ | Un fichier de configuration pour l' | ||
+ | |||
+ | / | ||
+ | |||
+ | / | ||
+ | |||
+ | La première ligne est pour inclure le répertoire propre de l' | ||
+ | |||
+ | **Compiling a console program | ||
To start, let us write a very simple program. This will serve just to test the compilation process, and see if units are in fact correctly detected. Choose File > New in the menu, and type in a test program (such as http:// | To start, let us write a very simple program. This will serve just to test the compilation process, and see if units are in fact correctly detected. Choose File > New in the menu, and type in a test program (such as http:// | ||
- | The program can be both compiled and executed in one step using command Ctrl+F9. The result is shown in the terminal, and execution goes back to the IDE whenever a key is pressed. | + | The program can be both compiled and executed in one step using command Ctrl+F9. The result is shown in the terminal, and execution goes back to the IDE whenever a key is pressed.** |
- | A first Free Vision application | + | Compiler un programme à la console |
+ | |||
+ | Pour commencer, écrivons un programme très simple. Il servira juste à tester le processus de compilation et voir si les unités sont bien correctement détectées. Choisissez File > New dans le menu et tapez un programme de test (tel que http:// | ||
+ | |||
+ | Le programme peut être compilé et exécuté en une étape en utilisant Ctrl-F9. Le résultat est présenté sur le terminal et l' | ||
+ | |||
+ | **A first Free Vision application | ||
Let us get on to using the modern equivalent of Borland’s Turbo Vision text-based user interface, now called Free Vision. The corresponding units are grouped in subdirectory: | Let us get on to using the modern equivalent of Borland’s Turbo Vision text-based user interface, now called Free Vision. The corresponding units are grouped in subdirectory: | ||
Ligne 52: | Ligne 96: | ||
The corresponding code is quite minimalistic. We have simply created a new application type, TMyApp, based on the pre-existing TApplication. This application is then instantiated in a variable. The application is initialized in method Init. Method Run is the main loop, where user keyboard and mouse events are handled. Finally, we clean up in method Done. That’s it - but it is already a working application, | The corresponding code is quite minimalistic. We have simply created a new application type, TMyApp, based on the pre-existing TApplication. This application is then instantiated in a variable. The application is initialized in method Init. Method Run is the main loop, where user keyboard and mouse events are handled. Finally, we clean up in method Done. That’s it - but it is already a working application, | ||
+ | |||
+ | var MyApp : TMyApp; | ||
+ | |||
+ | begin | ||
+ | MyApp.Init; | ||
+ | MyApp.Run; | ||
+ | MyApp.Done; | ||
+ | end.** | ||
+ | |||
+ | Une première application avec Free Vision | ||
+ | |||
+ | Continuons en utilisant l' | ||
+ | |||
+ | / | ||
+ | |||
+ | La première à utiliser est l' | ||
+ | |||
+ | Le code correspondant est très minimaliste. Nous avons simplement créé un nouveau type d' | ||
var MyApp : TMyApp; | var MyApp : TMyApp; | ||
Ligne 61: | Ligne 123: | ||
end. | end. | ||
- | One point that can be noticed is that the resulting executable files are rather small, even if using FreeVision. The first one - using merely Crt - takes up about 400 kBytes, and the second - with fv - takes less than 800 kBytes. This is quite small by modern standards. | + | **One point that can be noticed is that the resulting executable files are rather small, even if using FreeVision. The first one - using merely Crt - takes up about 400 kBytes, and the second - with fv - takes less than 800 kBytes. This is quite small by modern standards. |
+ | |||
+ | $ ls -lh test? test?.pas | ||
+ | -rwxrwxr-x 1 alan alan 416K jun 7 09:05 test1 | ||
+ | -rw-rw-r-- 1 alan alan 175 jun 7 09:04 test1.pas | ||
+ | -rwxrwxr-x 1 alan alan 781K jun 7 09:06 test2 | ||
+ | -rw-rw-r-- 1 alan alan 162 jun 7 08:45 test2.pas | ||
+ | |||
+ | This will be all for this first part in our series on Free Pascal - and Free Vision. In the next part, we will make the user interface responsive, and create some simple dialog windows.** | ||
+ | |||
+ | Un point qui peut être noté est que les fichiers exécutables résultants sont plutôt petits, même en utilisant Free Vision. Le premier, utilisant seulement Crt, prend environ 400 Ko, et le second, avec fv, prend moins de 800 Ko. C'est vraiment petit selon les normes modernes. | ||
$ ls -lh test? test?.pas | $ ls -lh test? test?.pas | ||
Ligne 69: | Ligne 141: | ||
-rw-rw-r-- 1 alan alan 162 jun 7 08:45 test2.pas | -rw-rw-r-- 1 alan alan 162 jun 7 08:45 test2.pas | ||
- | This will be all for this first part in our series on Free Pascal | + | Ce sera tout pour cette première partie de notre série sur Free Pascal |
issue111/tutoriel2.1469968071.txt.gz · Dernière modification : 2016/07/31 14:27 de auntiee