Difference between revisions of "Lazarus Tutorial/fi"

From Free Pascal wiki
Jump to navigationJump to search
Line 25: Line 25:
 
procedure TForm1.Button1Click(Sender: TObject);
 
procedure TForm1.Button1Click(Sender: TObject);
 
begin
 
begin
   {Kirjoita tai kopio&liitä tämä puuttuva osa:}   Button1.caption := 'Press again';
+
   {Kirjoita tai kopio&liitä tämä puuttuva osa:}
 +
  Button1.caption := 'Press again';
 
   {Lähdekoodieditori on jo täydentänyt aliohjelman lopun}
 
   {Lähdekoodieditori on jo täydentänyt aliohjelman lopun}
 
end;
 
end;
Line 108: Line 109:
 
Kuten tavallista, vaihtoehdot voidaan valita joko asettamalla hiiren osoitin valikkokohdan ja klikkaamalla hiiren vasenta painiketta.
 
Kuten tavallista, vaihtoehdot voidaan valita joko asettamalla hiiren osoitin valikkokohdan ja klikkaamalla hiiren vasenta painiketta.
  
==== Tiedostovalikko ====
+
==== Tiedosto-valikko ====
  
 
<div class="floatright"> [[Image:FileMenu.jpg]] </div>
 
<div class="floatright"> [[Image:FileMenu.jpg]] </div>
Line 150: Line 151:
 
<div style="clear:both;"></div>
 
<div style="clear:both;"></div>
  
==== Etsi valikko ====
+
==== Etsi-valikko ====
  
 
<div class="floatright"> [[Image:SearchMenu.jpg]] </div>
 
<div class="floatright"> [[Image:SearchMenu.jpg]] </div>
Line 187: Line 188:
 
* '''Lähdekoodieditori''': Pääikkuna, jossa lähdekoodia muokataan. Sen käyttäminen on samantapaista kuin muiden graafisten tekstieditorien: kursorin voi siirtää hiirellä tekstiin, klikkaamalla hiiren vasenta painiketta, vetämällä hiirellä voidaan valita ja korostaa tekstiä. Klikkaamalla hiiren oikeaa painiketta niin näytetään ponnahdusvalikko. Se sisältää mm tavalliset muokkaustoiminnot: leikkaa, kopioi ja liitä. Niiden lisäksi muita toimintoja kuten: Etsi määrittely ja Avaa tiedosto. Lähdekoodieditorin yläosassa on useita välilehtiä, jotka vastaavat tiedostoja, jotka ovat avoinna nykyisessä projektissa. Klikkaamalla välilehteä tuodaan kyseinen tiedosto näkyviin. Näin voidaan siirtyä helposti tiedostosta toiseen, kopioida tiedostojen välillä ja suorittaa suurimman osan normaalista muokkaustoimintoja. Lähdekoodieditori on värillinen koodin syntaksin korostus, jossa tuodaan erivärisenä välimerkit, kommentit, merkkijonovakiot jne. Se myös ylläpitää samaa sisennystä kun kirjoittaessa koodia siirrytään riviltä toiselle. Lähdekoodieditorin toiminnot ja ulkonäkö ovat hyvin monipuolisesti muokattavissa valitsemalla päävalikosta Työkalut->Asetukset -> Editori.
 
* '''Lähdekoodieditori''': Pääikkuna, jossa lähdekoodia muokataan. Sen käyttäminen on samantapaista kuin muiden graafisten tekstieditorien: kursorin voi siirtää hiirellä tekstiin, klikkaamalla hiiren vasenta painiketta, vetämällä hiirellä voidaan valita ja korostaa tekstiä. Klikkaamalla hiiren oikeaa painiketta niin näytetään ponnahdusvalikko. Se sisältää mm tavalliset muokkaustoiminnot: leikkaa, kopioi ja liitä. Niiden lisäksi muita toimintoja kuten: Etsi määrittely ja Avaa tiedosto. Lähdekoodieditorin yläosassa on useita välilehtiä, jotka vastaavat tiedostoja, jotka ovat avoinna nykyisessä projektissa. Klikkaamalla välilehteä tuodaan kyseinen tiedosto näkyviin. Näin voidaan siirtyä helposti tiedostosta toiseen, kopioida tiedostojen välillä ja suorittaa suurimman osan normaalista muokkaustoimintoja. Lähdekoodieditori on värillinen koodin syntaksin korostus, jossa tuodaan erivärisenä välimerkit, kommentit, merkkijonovakiot jne. Se myös ylläpitää samaa sisennystä kun kirjoittaessa koodia siirrytään riviltä toiselle. Lähdekoodieditorin toiminnot ja ulkonäkö ovat hyvin monipuolisesti muokattavissa valitsemalla päävalikosta Työkalut->Asetukset -> Editori.
  
* '''Code Explorer''': A window usually placed on the right of the Desktop which displays, in tree form, the structure of the code in the current unit or program.  It usually opens with just the Unit name and branches for Interface and Implementation sections, but clicking on the <div class="box">+</div> box to the left of any branch will open up its sub-branches or twigs, in more and more detail until individual constants, types and variables are displayed as well as procedure and function declarations.  If you change the file displayed in the main Source Editor window, you need to click on the Refresh button of the Code Explorer to display the structure of the new file.
+
* '''Kääntäjän viestit''': ikkuna, joka näyttää kääntäjän viestejä osoittaa kääntämisen edistymistä onnistuen tai luetellen havaittuja virheitä.
* '''Units...''': Opens a pop-up dialog window with a list of the unit files in the current project.Clicking with the mouse on a filename selects that file; click on Open to display that file in the Source Editor. Checking the Multi box allows several files to be selected simultaneously, and they will all be opened in the Source Editor (but only one at a time will be displayed).  This Menu Option is rather like the Project -> Project Inspector option, but only displays the list of Unit files and allows them to be opened.
+
 
* '''Forms...''': Opens a pop-up dialog window with a list of the Forms in the current project, and allows the selection of one or more of them for display.
+
* '''Koodin tutkija''': Ikkuna oletusarvoisesti sijoitettu työpyödän oikealla puolella, se näyttää käytettävän käännösyksikön tai ohjelman koodin rakenteen puun muodossa. Se avautuu yleensä vain näyttäen käännösyksikön nimen ja Interface ja Implementation lohkot, mutta klikkaamalla pientä kolmiota vasemmalla niin avautuu se enemmän ja tarkemmin, kunnes yksittäiset vakiot ja muuttujat näkyvät sekä aliohjelma että funktiomäärittelyt. Jos muutetaan tiedostoa lähdekoodieditorissa, niin täytyy klikata Päivitä-painiketta jotta koodin tutkija näyttää muutetun tiedoston uuden rakenteen.  
* '''View Unit Dependencies''': Opens a pop-up dialog window that shows, in a tree-like manner, the structure of dependencies of the currently open unit file. Most of the files listed as dependencies will have their own <div class="box">+</div> boxes, which allow the dependencies of the individual files to be explored, often in a highly recursive manner.
+
 
* '''Messages''': A window that displays compiler messages, showing the progress of a successful compilation or listing the errors found.
+
* '''Näytä käännösyksikön riippuvuudet''': Avaa ikkunan, joka näyttää puumaisella tavalla  avoinna käännösyksikön rakenteen riippuvuudet. Useimmilla lueteltuilla tiedostoilla on riippuvuuksia. Näillä on omat "laajennuskolmiot"
* '''Search Results''': A window that displays the results of find in files.
+
jotka näyttävät riippuvuudet. Yksitäistä tiedostoa tutkittaessa, riippuvuudet tulee esiin usein hyvin rekursiivisella tavalla.
* '''Debug windows''': Opens a pop-up menu with several options for operating and configuring the Debugger. See below where the [[#The_Debugger|debugger]] is described.
+
 
 +
* '''Hakutulokset''': ikkuna, joka näyttää tiedostoista haun tulokset.
 +
 
 +
* '''Virheenjäljitysikkunat''': Avaa ponnahdusvalikonjossa useita vaihtoehtoja virheenjäljittimen käyttöön ja konfigurointiin. Katso [[#Virheenjäljitys]]kappaletta.
 
<div style="clear:both;"></div>
 
<div style="clear:both;"></div>
  
==== The Source Menu ====
+
==== Lähdekoodi-valikko ====
 
<div class="floatright"> [[Image:SourceMenu.jpg]] </div>
 
<div class="floatright"> [[Image:SourceMenu.jpg]] </div>
* '''Comment Selection''': Comment out the currently selected text.
+
* '''Kommentoi valinta''': Kommentoi valitun tekstin.
* '''Uncomment Selection''': Uncomment the currently selected text.
+
* '''Poista valinnan kommentti''': Poistaa valitun tekstin kommentointi.
* '''Toggle Comment in Selection''': Comment out or uncomment the currently selected text.
+
* '''Valinnan kommentti päälle/pois''':Kommentoi tai poistaa valitun tekstin kommentoinnin.
* '''Enclose Selection...''': Enclose the currently selected text with a statement such as Try...Finally.
+
 
* '''Enclose in $IFDEF...''': Enclose the currently selected text with an IFDEF (conditional defines) statement.
+
* '''Kapseloi valinta...''': Kapseloi valitun tekstin valitun rakenteen sisään kuten esimerkiksi Try...Finally.
* '''Complete Code''':  
+
* '''Kapseloi $IFDEF:n sisään...''': Kapseloi valitun tekstin  IFDEF (Ehdollinen määrittely) rakenteen sisään.
* '''Add Unit to Uses Section''': Add one or more Units to the uses section in the current file.
+
* '''täydennä koodi''':  
* '''Refactoring''': Open the Refactoring sub-menu.
+
* '''Lisää käännösyksikkö uses-lauseeseen...''': Lisää yhden tai useamman käännösyksikön uses-lauseeseen.
* '''Quick Syntax Check''': Run a quick syntax check.
+
* '''Järjestele uudelleen''': Avaa järjestele uudelleen alavalikon.
* '''Guess Enclosed Block''': Let the editor end the enclosed block, such as a missing "End" in an "If" statement.  
+
* '''Nopea kieliopin tarkistus''': Suorittaa nopean kieliopin tarkistuksen.
* '''Guess Misplaced IFDEF/ENDIF''': Let the editor correct a misplaced conditional defines statement.  
+
* '''Arvaa sulkematta jäänyt lohko''': Antaa editorin lopettaa suljettu lohko, kuten puuttuva "End" käytettäessä "If" lausetta.
* '''Insert CVS Keyword...''': Insert a CVS keyword, such as "Author" or "Date".
+
* '''Arvaa väärinsijoitettu IFDEF/ENDIF''': Antaa editorin korjata puuttuva ehdollinen määrittely.
* '''Insert General''': Insert a general value, such as a "GPL Statement".
+
* '''Liitä CVS-sana...''': Liittää  CVS-avainsanan, kuten "Author" tai "Date".
* '''Insert Full Filename...''': Insert the filename.
+
* '''Liitä kenttiä''': Liittää yleisiä arvoja kuten "GPL ilmoitus".
* '''Insert ToDo''': Insert a ToDo comment.
+
* '''Lisää tiedoston koko nimi...''': Valitaan tiedosto jonka nimi polkuineen lisätään.
* '''Unit Information...''': Display information about the current unit.
+
* '''Lisää ToDo-merkintä''': Lisää ToDo-kommentin.
* '''Unit Dependencies...''': Display the dependencies for the current unit.
+
* '''Käännösyksikön tietoja...''': Näyttää tietoja käännösyksiköstä.
* '''JEDI Code Format''': View the JEDI Code Format options for the project.
+
* '''JEDI Code Format''': Näyttää JEDI Code Format optiot projektista.
  
==== The Project Menu ====
+
==== Projekti-valikko ====
 
<div class="floatright"> [[Image:ProjectMenu.jpg]] </div>
 
<div class="floatright"> [[Image:ProjectMenu.jpg]] </div>
* '''New Project''': Create a new project. A pop-up dialog window appears offering a choice of types of project to create.
+
 
* '''New Project from File''': A Navigation dialog window appears, alowing selection of a file from which to create a new project.
+
* '''Uusi projekti''': Luo uuden projektin. Ponnahdusikkuna avautuu josta valitaan minkä tyyppinen projekti on.
* '''Open Project''' Open a project which has already been created and saved. A navigation dialog appears with a list of Lazarus Project Information (.lpi) files from which a project may be chosen.
+
 
* '''Open Recent Project''': Displays a pop-up list of recent projects on which you have been working, and allows selection of one of these.
+
* '''Luo uusi projekti tiedostosta''': Navigation valintaikkuna avautuu, sallien valita tiedoston, josta luodaan uusi projekti.
* '''Close Project''' Close the current project.
+
 
* '''Save Project''': Similar to File -> Save: all the files of the current project are saved; if they have not previously been saved, there is a prompt for filename(s)- similar to Save Project As...
+
* '''Avaa projekti''' Avaa projektin, joka on jo luotu ja tallennettu. Valintaikkuna näkyy luettelona kyseisen kansion Lazarus Project Information (.lpi) tiedostoja, joista projekti voidaan valita.  
* '''Save Project As...''': Prompts for filename to save project. A default filename of Project1.lpi is offered, but you should choose your own filename. Lazarus will not permit you to use the same name for the Project file and the Unit File (see [[Lazarus Tutorial#The_Lazarus_files| below]]).
+
* '''Avaa esillä ollut Projekti''': Näyttää pop-up luettelon viimeaikaisista projekteista, joita on aikaisemmin avattu Lazaruksessa ja mahdollistaa valinta yhden näistä.
* '''Publish Project''': Creates a copy of the whole project. If you want to send someone just the sources and compiler settings of your code, this function is your friend. A normal project directory contains a lot of information. Most of it is not needed to be published: the .lpi file contains session information (like caret position and bookmarks of closed units) and the project directory contains a lot of .ppu, .o files and the executable. To create a lpi file with only the base information and only the sources, along with all sub directories use "Publish Project". In the dialog you can setup the exclude and include filter, and with the command after you can compress the output into one archive. See [[Lazarus IDE Tools]]
+
* '''Sulje projekti''' Sulkee avoinna olevan projektin.  
 +
* '''Tallenna projekti''': Samanlainen kuin Tiedosto -> Tallenna: kaikki avoinna olevan projektin tiedostot tallennetaan; jos niitä ei ole aiemmin tallennettu, kysytään tiedostonimi - samanlailla kuin "Tallenna projekti nimellä..." .
 +
* '''Tallenna projekti nimellä...''': Kysyy projektin tiedostonimeä jolla se tallennetaan . Oletuksena tiedostonimi on Project1.lpi, mutta olisi parempi valita sovellusta kuvaavampi tiedostonimi. Lazarus ei salli että käytettäisiin samaa nimeä projektin ja käännösyksikön tiedostoniminä (katso [[Lazarus Tutorial/fi#Lazarus_tiedostot| alla ]]).
 +
 
 +
* '''Julkaise projekti...''': Luo kopion koko projektista. Jos haluat lähettää jollekin vain lähdekoodin ja kääntäjän asetukset, tämä toiminto on ystäväsi. Normaali projektikansio sisältää paljon tietoa. Suurinta osaa siitä ei tarvitse julkaista: Tällä .lpi tiedosto sisältää istunnon tiedot (kuten kursorin asema ja suljettujen käännösyksikköjen kirjaimerkit) ja projektikansio sisältää paljon .ppu, .o tiedostoja ja ajettavan tiedoston. "Julkaise projektin" luomma lpi tiedosto sisältää  vain perustietoa ja  lähdekoodia sekä alikansioita. Dialogissa voidaan asettaa sulkevan poistosuodattimen ja sisältävän lisäyssuodattimen ja komennolla "komento jälkeen" voit pakata tuotoksen yhdeksi arkistotiedostoksi. Katso [[Lazarus IDE Tools|Lazarus IDE Työkalut]]
 
* '''Project Inspector''': Opens a pop-up dialog with a tree-like display of the files in the current project.  Allows you to add, remove or open selected files, or change options of the project.
 
* '''Project Inspector''': Opens a pop-up dialog with a tree-like display of the files in the current project.  Allows you to add, remove or open selected files, or change options of the project.
 
* '''Project Options...''': Opens a pop-up dialog window with tabs for setting options for Application (Title, Output Target file name), Forms (allowing you to select among the available forms, make them Auto-create at start of application) and Info (specifying whether editor information should be saved for closed files, or only for project files).
 
* '''Project Options...''': Opens a pop-up dialog window with tabs for setting options for Application (Title, Output Target file name), Forms (allowing you to select among the available forms, make them Auto-create at start of application) and Info (specifying whether editor information should be saved for closed files, or only for project files).
 +
* '''Units...''': Opens a pop-up dialog window with a list of the unit files in the current project.Clicking with the mouse on a filename selects that file; click on Open to display that file in the Source Editor.  Checking the Multi box allows several files to be selected simultaneously, and they will all be opened in the Source Editor (but only one at a time will be displayed).  This Menu Option is rather like the Project -> Project Inspector option, but only displays the list of Unit files and allows them to be opened.
 +
* '''Forms...''': Opens a pop-up dialog window with a list of the Forms in the current project, and allows the selection of one or more of them for display.
 +
 
* '''Compiler options ...''': (Recently moved here from the Run Menu). Opens a multi-page tabbed window which allows configuration of the compiler.  Tabs include '''Paths''' which allows definition of search paths for units, include files, libraries etc, as well as allowing choice of widget type for the forms (gtk, gnome, win32); '''Parsing''' which allows choice of rules for parsing source programs, '''Code''' which allows choice of optimisation for faster or smaller programs, choice of target processor, types of checks, heap size etc; '''Linking''' allowing choice of whether or how to use debugging, static or dynamic libraries, and whether to pass options through to the linker; '''Messages''' to define what type of messages should be generated during error conditions; '''Other''' which allows decision to use default configuration file (fpc.cfg) or some other file; '''Inherited''' which shows a tree structure diagram to indicate how options have been inherited from units already incorporated; '''Compilation''' which allows definition of commands to be executed before or after the compiler is launched and can allow use of Make files.  
 
* '''Compiler options ...''': (Recently moved here from the Run Menu). Opens a multi-page tabbed window which allows configuration of the compiler.  Tabs include '''Paths''' which allows definition of search paths for units, include files, libraries etc, as well as allowing choice of widget type for the forms (gtk, gnome, win32); '''Parsing''' which allows choice of rules for parsing source programs, '''Code''' which allows choice of optimisation for faster or smaller programs, choice of target processor, types of checks, heap size etc; '''Linking''' allowing choice of whether or how to use debugging, static or dynamic libraries, and whether to pass options through to the linker; '''Messages''' to define what type of messages should be generated during error conditions; '''Other''' which allows decision to use default configuration file (fpc.cfg) or some other file; '''Inherited''' which shows a tree structure diagram to indicate how options have been inherited from units already incorporated; '''Compilation''' which allows definition of commands to be executed before or after the compiler is launched and can allow use of Make files.  
 
* '''Add Editor File to Project''': Add the file currently being edited to the Project
 
* '''Add Editor File to Project''': Add the file currently being edited to the Project
Line 661: Line 672:
 
By default, a number of standard actions are pre-loaded from ''StdActns'' or, if DataAware controls are used, from ''DBActns''. These actions can be chosen using the ActionList editor which appears when you right-click on the ActionList icon on the Form Designer.
 
By default, a number of standard actions are pre-loaded from ''StdActns'' or, if DataAware controls are used, from ''DBActns''. These actions can be chosen using the ActionList editor which appears when you right-click on the ActionList icon on the Form Designer.
  
== The Debugger ==
+
== Virheenjäljitys ==
 
: ''Still to be written''.
 
: ''Still to be written''.
  
Line 671: Line 682:
 
This page also helps with some platform/version specific issues
 
This page also helps with some platform/version specific issues
  
== The Lazarus files ==
+
== Lazarus tiedostot ==
 
     (Thanks to Kevin Whitefoot.)
 
     (Thanks to Kevin Whitefoot.)
 
     (Additions by Giuseppe Ridinò, [[User:Kirkpatc]] and Tom Lisjac)
 
     (Additions by Giuseppe Ridinò, [[User:Kirkpatc]] and Tom Lisjac)

Revision as of 10:14, 9 December 2016

Deutsch (de) English (en) español (es) suomi (fi) français (fr) magyar (hu) italiano (it) 日本語 (ja) македонски (mk) Nederlands (nl) português (pt) русский (ru) slovenčina (sk) shqip (sq) 中文(中国大陆)‎ (zh_CN) 中文(台灣)‎ (zh_TW)

Tästä alkaa Lazarus Tutorial. Voit vapaasti parantaa sitä.

Yleistä

Lazarus on vapaa avoimeen lähdekoodiin perustuva ohjelmankehitysympäristö joka pohjautuu FreePascal Compiler (object pascal), Joka on myös vapaa ja avointa lähdekoodia. Lazarus käyttöliittymä { kuvakaappaus) on vakaa ja ominaisuuksiltaan monipuolinen ohjelman kehitysympäristö jolla voi tehdä itsenäisiä graafisia ja komentorivillä toimivia sovelluksia. Se toimii Linux:ssa, FreeBSD:ssä, Win32:ssa, Mac:ssa ja on varustettu customoitavalla lähdekoodieditorilla ja visuaalisella lomakkeen muotoilulla jossa mukana komponenttipakettienhallinta, virheenjäljitin ja täydellinen graafinen käyttöliittymäkomponentit integoroituna FreePascal kääntäjään.

Aloittaminen

Hanki, asenna ja käynnistä Lazarus jossa pitää olla Free Pascal Compiler mukana.

Light bulb  Huomaa: Ainakin Linux Ubuntu, Lasaruksen käynnistyskomento on konsolissa "startlazarus". Jos olet asentanut Lazaruksen Debianin pakettina, niin Lazarus pitäisi olla valikkokohdan Sovellus / ohjelmointi alla. (Huomaa: Debian ja Ubuntu tärkeimmät binary ja paketti on nimeltään "Lazarus-ide", koska on myös "TCT" paketti jossa mukana tulee apuohjelma nimeltä "Lazarus").

Ensimmäinen Lazarus ohjelma!

Päävalikosta valitsemalla Projekti-Uusi projekti-Sovellus (tai: Tiedosto-Uusi-projekti-Sovellus)niin uusi graafinen sovellus luodaan, katso myös Form opetusohjelma .

Useita ikkunoita ilmestyy työpöydälle: Päävalikkoikkuna yläreunassa, Komponenttimuokkain on vasemmalla, "Lähdekoodieditori" täyttää työpöydän ja valmis lomake "Form1" on omassa ikkunassa (Form1 ) Lähdekoodieditorin päällä.

Jos halutaan sijoittaa painike lomakkeelle: Päävalikkoikkunan alaosassa on välilehtirivi. Jos "Standard" välilehti ei ole jo valittu, valitse se klikkaamalla hiirellä. Sen jälkeen etsii Button kuvakkeen (suorakulmio jossa on "OK"-teksti) ja klikkaa sitä hiirellä. Sitten Form1 ikkunassa klikataan jonnekin keskilinjan vasemmalla puolen. Varjostettu "Button1"-tekstillä merkitty suorakulmio ilmestyy siihen. Klikkaa jälleen Button kuvaketta Standard -välilehdellä ja klikkaa Form1-ikkunassa jonnekin oikealle keskelle: toinen "Button2"-tekstillä merkitty suorakulmio ilmestyy.

Nyt klikkaa Button1 jotta se valitaan. Komponenttimuokkainikkuna näyttää nyt kohteen Button1-ominaisuudet. Yläosassa on ominaisuus nimeltä 'Caption', jossa näytetään arvo "Button1". Klikkaa kyseistä kohtaa (ruudukkoa) ja muuta teksti "Button1" muotoon "Press". Jos painat Enter tai klikkaat toista ruutua näet että Form1-lomakkella ensimmäisen painikkeen teksti muuttuu "Press":ksi. Nyt klikkaat Tapahtumat -välilehteä komponenttimuokkaimessa niin näet erilaisia ​​tapahtumia, jotka voivat liittyä tähän Button1-painikkeeseen. Näitä ovat onClick, OnEnter, OnExit jne. Valitse onClick oikealla puolella oleva ruutu. Tällöin siihen ilmestyy pienempi laatikko kolmella pisteellä (...). Kun klikkaat tätä, se otetaan automaattisesti osaksi lähdekoodieditorissa ja kursorin sijoitetaan koodinpätkän keskelle:

procedure TForm1.Button1Click(Sender: TObject);
begin
  {Kirjoita tai kopio&liitä tämä puuttuva osa:}  
  Button1.caption := 'Press again';
  {Lähdekoodieditori on jo täydentänyt aliohjelman lopun}
end;


Painamalla F12 nähdään lähdekoodieditorin sijasta lomakkeen Form1 ikkuna.

Nyt muokataan Button2 ominaisuuksia : klikkaa Button2 jotta nähdään sen ominaisuuksia komponenttimuokkaimessa. Muuta sen Caption omainaisuuteen "Button2" tekstin tilalle "Exit". Valitse tapahtumat-välilehti ja klikkaa onClick. Klikkaa kolme pistettä (...) ja sen jälkeen ollaan lähdekoodieditorissa, keskellä toisen Button2:n aliohjelmaa:

procedure TForm1.Button2Click(Sender: TObject);
begin
  {Kirjoita tai kopio&liitä tämä puuttuva osa:}    
   Close;
  {Lähdekoodieditori on jo täydentänyt aliohjelman lopun} 
end;

Painamalla F12 nähdään lomakkeen Form1 ikkuna uudelleen. Tallenna nyt työsi (ja muista tehdä se usein !!) valitsemalla päävalikosta Projekti-Tallenna projekti nimellä> sinun_valitsemalla_tiedosto_nimellä. Talletettavana on kaksi erilaista tiedostonimipäätettä (*.pas ja *.lpi). Valitse näille eri nimet. Jos molemmat ovat samannimisiä niin saat "duplicate identifier" käännösvirheen (katso luku "The Lazarus tiedostot" lopussa tämän aiheen lopussa).

Voit nyt yrittää kääntää. Yksinkertaisin tapa tehdä on valita "Suorita" päävalikon yläreunasta ja sitten "Suorita" vaihtoehto alivalikosta. Vaihtoehtoisesti voit yksinkertaisesti painaa F9. Tämä ensin kääntää ja sitten (jos kaikki on hyvin) linkittää sekä suorittaa kyseisen ohjelman.

Kääntäjän viestit ikkuna tulee näkyville ja kaikenlaisia ​​kääntäjä viestejä siihen kirjoitetaan, mutta lopulta sinun Form1 ikkuna ilmestyy näyttöön uudelleen, mutta ilman ruudukon pisteitä. Tämä sovelluksesi pääikkuna ja se odottaa että sinä painat painonappeja tai olet muutoin vuorovaikutuksessa sen kanssa.

Kokeile klikkaamalla painiketta joka on nimetty tekstillä "Press". Huomaat, että sen teksti muuttuu "Press again" tekstiksi. Jos painat sitä uudelleen, sen teksti on silti "Press again" !!

Nyt klikkaat painiketta joka on nimetty tekstillä "Exit". Ikkuna sulkeutuu ja ohjelma päättyy. Alkuperäinen Form1 ikkuna ruudukon pisteillä ilmestyy uudelleen ja on valmis hyväksymään lisää muokkausta toimintaansa.

Muokkaa ohjelmaa

Uudelleen avaa tallennettu projekti. Sen Form1 ikkunassa klikkaa "Press" painiketta (Button1) valitseksesi se. Valitse "Tapahtumat" -välilehti komponenttimuokkaimessa, klikkaa onClick:n oikealla puolella olevaa ruutua, klikkaa kolme pistettä (...), jolloin siirryt oikeaan kohtaan lähdekoodieditorissa.

Muokkaa kyseinen kohta koodia seuraavanlaiseksi:

procedure TForm1.Button1Click(Sender: TObject);
{Hyödynnetään Tag ominaisuutta, se saa arvot 0 tai 1}
begin
  if Button1.tag = 0 then
  begin
    Button1.caption := 'Press again';
    Button1.tag := 1;
  end else
  begin
    Button1.caption := 'Press';
    Button1.tag := 0;
  end;
end;

Tallenna työsi, uudelleen käännä ja suorita. Vasen painike nyt vaihtaa tekstiä kahden vaihtoehdon välillä.

Loput on sinusta kiinni!

Jos haluat kirjoittaa konsoli- tai tekstipohjaisia Pascal ohjelmia (esimerkiksi jos seuraavana on perustiedot Pascal ohjelmoinnista kurssi tai täytyy kirjoittaa ohjelmia joita käytetään eräajona tai järjestelmäohjelmointia), voit silti käyttää Lazarus muokkaamaan , kääntämään ja ajamaan ohjelmia. Katso Console Mode Pascal.


Kehitysympäristön ikkunat

Kun käynnistää Lazarus ensimmäistä kertaa niin joukko erillisiä irti olevia tai "kelluvia" ikkunoita näkyy työpöydällä.

Ensimmäinen, oikealla yläreunassa pitkittäin on otsikoitu "project1 - Lazarus IDE vXXXXXX" (jonka nimi muuttuu vastaamaan nimiä parhaillaan auki olevasta projektista). Tämä on tärkein ikkunan ja se sisältää mm päävalikon ja komponenttipaletin.

Lazarus-IDE.jpg

Otsikkopalkin alapuolella oleva rivi on päävalikko jossa on merkinnät Tiedosto, Muokka, Etsi, Näytä ja niin edelleen. Tämän alapuolella vasemmalla on joukko symboleja (kuvakkeita jotka vievät nopeasti tiettyihin valikkokomentoihin) ja oikealla on komponenttipaletti.

Tämän alle vasemmalla on komponenttimuokkain ('Object Inspector') ikkuna ja Lazaruksen lähdekoodieditori oikealla. Siellä voi olla toinen pienempi ikkuna joka on (aluksi) merkitty nimellä "Form1", Lazaruksen lähdekoodi-ikkunan päällä. Jos tämä ei ole näkyvissä heti, se voidaan saada näkymään painamalla F12. Kyseinen funktionäppäin vaihtaa vuorotellen lähdekoodieditorin ja lomakenäkymän välillä. Lomake (Form) ikkuna on se, johon voidaan rakentaa graafisen käyttöliittymän sovellukseen, kun taas lähdekoodieditorin ikkuna näyttää sovelluksen Pascal koodin jota kehitetään. Komponenttimuokkaimen toiminta on käsitelty tarkemmin alla, kun komponenttipaletti on ensin kuvattu. Lisäksi voi olla myös viesti -ikkuna näytön alareunassa: tätä käytetään näyttämään Lazaruksen palautetta ohjelmoijalle, esimerkiksi ohjelmaa käännettäessä.

Kun aloittaa uuden projektin (tai kun käynnistää Lazarus ohjelman kehitysympäristön) niin oletus lomake rakennetaan, joka koostuu laatikosta, jossa on pisteruudukko, joiden avulla voit sijoittaa eri komponentteja lomakkeelle ja lomakkeen yläpalkki, joka sisältää tavallisesti minimointi, maximointi ja Sulje-painikkeet. Jos klikkaat hiiren kohdistimella mihin tahansa tähän lomakkeeseen, näet vasemmalla puolen komponenttimuokkaimen joka kertoo tämän lomakkeen ominaisuuksia.

Muut ikkunat, jotka voivat tulla näkyviin työskentelyn aikana: Projektin hallinta, joka sisältää yksityiskohtaiset tiedot tiedostojen mukana olosta projektissa. Siinä voidaan lisätä tai poistaa tiedostoja projektista; Viesti-ikkuna, joka näyttää kääntäjän viestejä, virheitä tai edistymisraportteja projektista. Jos Lazarus käynnistettiin pääteikkunasta (konsoli) niin alkuperäinen pääteikkuna pysyy näkyvissä ja yksityiskohtaiset kääntäjän viestit tulostetaan myös siellä.


Päävalikko

Päävalikko sisältää seuraavat nimikkeet: Tiedosto, Muokkaa, Etsi, Näytä, Lähdekoodi, Projekti, Suorita, Paketti, Työkalut, Ikkunat ja Ohje.

Kuten tavallista, vaihtoehdot voidaan valita joko asettamalla hiiren osoitin valikkokohdan ja klikkaamalla hiiren vasenta painiketta.

Tiedosto-valikko

FileMenu.jpg
  • Uusi käännösyksikkö: Luo uuden käännösyksikön (unit)tiedoston (Pascal koodi).
  • Uusi lomake: Luo uuden lomakkeen: siis molemmat visuaalinen lomakkeen ja siihen liittyvän käännösyksikön.
  • Uusi ...: Tarjoaa pop-up-valikon, jolla on mahdollista luoda erilaisia uusia dokumenttityyppejä.
  • Avaa: Tarjoaa pop-up-valintaikkunan, jolla voidaan navigoida tiedostojärjestelmässä ja valita olemassa tiedosto joka avataan.
  • Palauta: Hylkää muokatut muutokset ja palauttaa tiedoston sen alkuperäiseen tilaan.
  • Avaa esillä ollut: Tarjoaa luettelon äskettäin muokattuja tiedostoja ja niistä on mahdollisuus valita yksi.
  • Tallenna: Tallentaa nykyisen tiedoston käyttäen alkuperäistä tiedostonimeä. Jos sillä ei ole nimeä, järjestelmä kysyy nimeä (kuten Tallenna nimellä).
  • Tallenna nimellä: Voidaan valita kansio ja tiedostonimi kun tallentaa käytettävän tiedoston.
  • Tallenna kaikki: Tallentaa kaikki lähdekoodieditorin tiedostot, ei vain yhtä.
  • Vie HTML:nä: Vie nykyisen tiedoston sisällön uuteen tiedostoon HTML-muodossa.
  • Sulje välilehti: Sulkee nykyisen tiedoston, varmistaen että tallennetaako kaikki editorin muutokset.
  • Sulje kaikki: Sulkee kaikki editorin tiedostot. Kysyy tallennetaanko jos jossakin niistä on tallentamatta muutoksia.
  • Siivoa hakemisto: Tarjoaa dialogin jossa on joukko muokattavissa olevia suodattimia tiedostojen poistamiseksi hakemistossa. Hyödyllisiä *.bak tiedostojen poistoon ja entisten Delphi projektien jäänteiden poistoon.
  • Tulosta: Käyttää järjestelmän tulostinta tulostaessa valittua tiedostoa. Tämä valinta ei ehkä näy oletusarvoisesti, jos et käytä windowsia. Jos ei näy niin sitten täytyy asentaa $Lazdir/components/printers/design/printers4lazide.pas ja kääntää lazarus kehitysympäristö uudelleen.
  • Käynnistä Lazarus uudelleen: Käynnistää Lazaruksen - hyödyllinen jos tiedostot ovat menneet toivottoman sekaiseksi!
  • Lopeta: Lopettaa Lazaruksen käytön , varmistaen että kaikki muokatut tiedostot tallennetaan.

Muokkaa-valikko

EditMenu.jpg
  • Kumoa: Kumoa viimeisin muokkaus toiminto, jättäen editorin tilaan joka oli juuri ennen viimeistä toimintaa.
  • Tee uudelleen: Tekee uudelleen viimeisen toiminnon, joka purettiin kumoa valinnalla.
  • Leikkaa: Poistaa valitun tekstin tai muun kohteen ja asetaa sen leikepöydälle.
  • Kopioi: Tekee kopion valitusta tekstistä, jättää alkuperäisen paikalleen ja asettamalla kopion leikepöydälle.
  • Liitä: Asettaa sisällön leikepöydältä osoittimen kohdalle. Jos valittua tekstiä on osoittimen kohdalla, leikepöydän sisältö korvaa valitun tekstin.
  • Valitse: Mahdollistaa valita tekstilohkoja. Vaihtoehtoja ovat Valitse kaikki, Valitse sulkuun asti, Valitse koodilohko, Valitse sana, Valitse rivi tai Valitse kappale.
  • Sisennä valinta: Siirrä valittua tekstiä oikealle määrällä joka on määritelty Työkalut -> Asetukset... -> Editori -> Yleistä -> Tab ja sisennys. Tämä ominaisuus on hyödyllinen kun muotoillaan Pascal lähdekoodin lohkorakennetta.
  • Poista valinnan sisennys: Poistaa yksi tasoa sisennystä, siirtämällä tekstiä vasemmalle ennalta valitulla määrällä.
  • Valinta isoiksi kirjaimiksi: Muuntaa valitun tekstin isoiksi kirjaimiksi.
  • Valinta pieniksi kirjaimiksi: Muuntaa valitun tekstin pieniksi kirjaimiksi.
  • Käännä kirjainten koko valinnassa: Kääntää valitun tekstin pienet kirjaimet isoiksi ja isot pieniksi.
  • Järjestä valinta: Lajittelee rivit (tai sanoja tai kappaleista) aakkosjärjestykseen; vaihtoehtoja nouseva tai laskeva järjestys, kirjainkoko huomioiden tai jätetään huomioitta. Keskellä ohjelman lähdekoodia, ei tietenkään, ole järkevää, mutta jos on jokin luettelo joka täytyy olla järjestetty niin silloin.
  • Muuta tabit välilyönneiksi valinnassa: Korvaa valitun tekstin kaikki tabit tietyllä määrällä välilyöntejä joka on määritelty Työkalut -> Asetukset... -> Editori -> Yleistä -> Tab ja sisennys.
  • Rivitä valinta uudelleen: Jos valitun tekstin rivit ovat pidempiä kuin 80 merkkiä tai luvun joka määritetty kohdassa Työkalut -> Asetukset... -> Editori -> Yleistä -> Näkymä -> Marginaali ja reunapalkki olevan merkkimäärän niin loppurivi jatkuu seuraavalla rivillä .
  • Lisää merkkitaulukosta: Mahdollistaa näppäimistöltä löytymättömien , kuten aksenttimerkkien, merkkien lisäämisen. Merkki poimitaan "pop-up" ikkunan merkkikartalta.

Etsi-valikko

SearchMenu.jpg
  • Etsi: Samanlainen ominaisuus kuin lähes kaikissa graafisissa editoreissa: pop-up valintaikkuna mahdollistaa merkkijonon etsimisen erilaisilla vaihtoehdoilla, kuten sama kirjaisinkoko, merkkijonon pitää olla kokonainen sana, etsinnän lähtöpiste, etsinnän laajuus ja etsintäsuunta.
  • Etsi seuraava, Etsi edellinen: Etsii uudelleen aiemmin kirjoitetun merkkijonon, määrättyyn suuntaan.
  • Etsi tiedostoista: Etsii merkkijonon tiedostoista: pop-up dialogi tarjoaa vaihtoehtoja kaikki avoimet tiedostot, kaikki projektin tiedostot tai kaikki hakemistot; läpikäytävien tiedostotyyppien valitsemiseksi voidaan antaa maskeja.
  • Etsi ja korvaa: Samanlainen kuin Etsi; näyttää ponnahdusvalintaikkunan jossa on paikka etsittävälle merkkijonolle ja sen korvaavalle merkkijonolle. Etsintää voi rajata erilaisilla vaihtoehdoilla kuten sama kirjaisinkoko, merkkijonon pitää olla kokonainen sana, etsinnän lähtöpiste, etsinnän laajuus ja etsintäsuunta.
  • Etsi kirjain kerrallaan:Etsii merkkijonon, sitä mukaa kuin kirjoittaa hakusanan. Esimerkki: kun valitset "Etsi kirjain kerrallaan" jos painat "l" ensimmäinen "l" on korostettu. Jos sitten painat "a" niin löydetään seuraavaksi "la" ja niin edelleen.
  • Mene riville: Siirtää kohdistimen määritellylle tiedoston riville.
  • Hyppää takaisin: Siirtyy edelliseen paikkaan. Jokakerta kun hyppätään virheeseen tai etsitään määrittely niin kehitysympäristö tallentaa kyseisen paikan. Tämän toiminnon avulla voidaan palata takaisin siihen missä oltiin aikaisemmin.
  • Hyppää eteenpäin: Siirtyy seuraavaan paikkaan. Kumoaa hyppää takaisin toiminnan.
  • Lisää hyppypiste historiaan: Lisää tämän hetkisen paikan hyppyhistoriatietoihin.
  • Hyppää seuraavaan virheeseen, Hyppää edelliseen virheeseen: Hyppää lähdekooditiedoston seuraavaan tai edelliseen raportoituun virheeseen.
  • Aseta vapaa kirjanmerkki: Merkitse nykyinen rivi jossa kursori sijaitsee seuraavaksi saatavilla (vapaana) olevalla kirjanmerkillä ja lisää tämä kirjanmerkkiluetteloon. Huomaa, että ponnahdusvalikossa (saadaan klikkaamalla hiiren oikealla näppäimellä lähdekoodieditorissa) on mahdollisesti suurempi joukko kirjanmerkkivalintoja, jolloin kirjanmerkin numeroa on täsmennettävä, tai joiden avulla käyttäjä voi siirtyä numeroituun kirjanmerkkiin, ei vain seuraavan tai aiemmat.
  • Siirry seuraavaan kirjainmerkkiin, Siirry edelliseen kirjainmerkkiin: Siirtyy seuraavaan tai edelliseen kirjanmerkkiin numerojärjestyksessä.
  • Etsi koodilohkon toinen pää: Jos sijaitaan varatun sanan begin kohdalla etsitään sitä vastaavaa end:iä tai päinvastoin.
  • Etsi koodilohkon alku: Siirtyy kyseisen aliohjelman tai funktion varattuun sanaan begin missä kursori sijaitsee.
  • Etsi määrittely: Etsii paikkaa, jossa valittu tunniste on määritelty. Tämä voi olla samassa tiedostossa tai toisessa, editorissa jo avoinna olevassa tiedostossa ja jos tiedosto ei ole auki, se avataan (joten jos aliohjelma tai funktio on esitelty, esimerkiksi tiedostossa classesh.inc niin tämä avataan editoriin). ( katso lisätietoa).
  • Avaa kursorin osoittama tiedosto: Avataan tiedosto, jonka nimi on valittu kursoriin. Hyödyllinen kun katsotaan Include tiedostoja tai tiedostoja, jotka sisältävät projektin muita käännösyksikköjä (Unit ) joita siinä on käytetty.
  • Siirry Include määrittelyyn':Jos kursori sijaitsee tiedostossa joka sisälletty (Included) toiseen tiedostoon

niin se siirtyy tähän tiedostoon missä on tämä Include kutsu.

  • Etsi viittauksia tunnisteihin: Tuottaa luettelon kaikista nykyisen tiedoston, nykyisen projektin tai kaikista liitetiedostojen riveistä jossa tunniste on mainittu.
  • Aliohjelma luettelo: Tuottaa luettelon kaikista aliohjelmista (procedure)ja funktioista (function) rivinumeroineen missä ne on määritelty jotka ovat nykyisessä tiedostossa.


Näytä-valikko

ViewMenu.jpg

Ohjaa näytön eri ikkunoita ja paneeleita ruudulla.

  • Siirry lomakkeen ja käännösyksikön välillä F12: Vaihtaa lähdekoodieditorin ja nykyisen lomakkeen välillä ja sijoittaa sen työpöydän pintakerrokseen päällimmäiseksi ja valitsee sen aktiiviseksi. Jos lähdekoodieditori tuli valituksi niin voidaan muokata lähdekoodia; Jos lomake tuli valituksi niin voidaan muokata komponentteja ja muokata lomakkeen muotoa. Helpoin tapa vaihtaa lähdekoodieditorin ja lomakkeen välillä on käyttää F12-näppäintä, mutta sama vaikutus saadaan valitsemalla tämä vaihtoehto päävalikosta.
  • Komponenttimuokkain: Ikkuna joka yleensä on työpöydän vasemmalla puolella, näyttää lomakkeen(Form) ominaisuudet joka on työpöydällä. Klikkaamalla hiirellä mitä tahansa komponenttia lomakkeella se aiheuttaa komponentin yksityiskohtien näytön komponenttimuokkaimessa. Yläosassa on paneeli, joka esittää projektin rakenteen puumaisena myös komponentit voidaan valita tässä paneelissa: tämän seurauksena myös vastaavat yksityiskohdat näytetään komponenttimuokkaimessa. Alemman paneelin tärkein asia on kaksi välilehteä, jotka näyttävät Ominaisuudet ja Tapahtumat välilehdet. Valitsemalla Ominaisuudet-välilehti niin nähdään ominaisuuksia, kuten nimi, väri, kuvateksti, fontti, koko jne. Siinä näytetään kaksi saraketta, vasenmpi näyttää ominaisuutta ja oikea osoittaa siihen liittyvän arvon. Myös välilehti Tapahtumat näyttää kaksi saraketta: vasenmalla luetellaan mahdolliset tapahtumat kuten MouseClick tai KeyDown jotka liittyvät kyseiseen komponenttiin. Oikealla näkyy toiminta, joka on kytketty kyseisen tapahtumaan. Jos ei ole toimintaa määritetty, niin se voidaan valita valitsemalla soveltuva kohta tai painamalla ...-painiketta. Painikkeen ... aiheuttaa sen että siirrytään lähdekoodieditoriin ja kohdistin sijoitettu tyhjän aliohjelman (Procedure) sisälle odottamaan tapahtuman määrittelevän koodin kirjoittamista. Kyseiselle aliohjelmalle on tehty kaikki muut vaadittavat määrittelyt.
  • Lähdekoodieditori: Pääikkuna, jossa lähdekoodia muokataan. Sen käyttäminen on samantapaista kuin muiden graafisten tekstieditorien: kursorin voi siirtää hiirellä tekstiin, klikkaamalla hiiren vasenta painiketta, vetämällä hiirellä voidaan valita ja korostaa tekstiä. Klikkaamalla hiiren oikeaa painiketta niin näytetään ponnahdusvalikko. Se sisältää mm tavalliset muokkaustoiminnot: leikkaa, kopioi ja liitä. Niiden lisäksi muita toimintoja kuten: Etsi määrittely ja Avaa tiedosto. Lähdekoodieditorin yläosassa on useita välilehtiä, jotka vastaavat tiedostoja, jotka ovat avoinna nykyisessä projektissa. Klikkaamalla välilehteä tuodaan kyseinen tiedosto näkyviin. Näin voidaan siirtyä helposti tiedostosta toiseen, kopioida tiedostojen välillä ja suorittaa suurimman osan normaalista muokkaustoimintoja. Lähdekoodieditori on värillinen koodin syntaksin korostus, jossa tuodaan erivärisenä välimerkit, kommentit, merkkijonovakiot jne. Se myös ylläpitää samaa sisennystä kun kirjoittaessa koodia siirrytään riviltä toiselle. Lähdekoodieditorin toiminnot ja ulkonäkö ovat hyvin monipuolisesti muokattavissa valitsemalla päävalikosta Työkalut->Asetukset -> Editori.
  • Kääntäjän viestit: ikkuna, joka näyttää kääntäjän viestejä osoittaa kääntämisen edistymistä onnistuen tai luetellen havaittuja virheitä.
  • Koodin tutkija: Ikkuna oletusarvoisesti sijoitettu työpyödän oikealla puolella, se näyttää käytettävän käännösyksikön tai ohjelman koodin rakenteen puun muodossa. Se avautuu yleensä vain näyttäen käännösyksikön nimen ja Interface ja Implementation lohkot, mutta klikkaamalla pientä kolmiota vasemmalla niin avautuu se enemmän ja tarkemmin, kunnes yksittäiset vakiot ja muuttujat näkyvät sekä aliohjelma että funktiomäärittelyt. Jos muutetaan tiedostoa lähdekoodieditorissa, niin täytyy klikata Päivitä-painiketta jotta koodin tutkija näyttää muutetun tiedoston uuden rakenteen.
  • Näytä käännösyksikön riippuvuudet: Avaa ikkunan, joka näyttää puumaisella tavalla avoinna käännösyksikön rakenteen riippuvuudet. Useimmilla lueteltuilla tiedostoilla on riippuvuuksia. Näillä on omat "laajennuskolmiot"

jotka näyttävät riippuvuudet. Yksitäistä tiedostoa tutkittaessa, riippuvuudet tulee esiin usein hyvin rekursiivisella tavalla.

  • Hakutulokset: ikkuna, joka näyttää tiedostoista haun tulokset.
  • Virheenjäljitysikkunat: Avaa ponnahdusvalikonjossa useita vaihtoehtoja virheenjäljittimen käyttöön ja konfigurointiin. Katso #Virheenjäljityskappaletta.

Lähdekoodi-valikko

SourceMenu.jpg
  • Kommentoi valinta: Kommentoi valitun tekstin.
  • Poista valinnan kommentti: Poistaa valitun tekstin kommentointi.
  • Valinnan kommentti päälle/pois:Kommentoi tai poistaa valitun tekstin kommentoinnin.
  • Kapseloi valinta...: Kapseloi valitun tekstin valitun rakenteen sisään kuten esimerkiksi Try...Finally.
  • Kapseloi $IFDEF:n sisään...: Kapseloi valitun tekstin IFDEF (Ehdollinen määrittely) rakenteen sisään.
  • täydennä koodi:
  • Lisää käännösyksikkö uses-lauseeseen...: Lisää yhden tai useamman käännösyksikön uses-lauseeseen.
  • Järjestele uudelleen: Avaa järjestele uudelleen alavalikon.
  • Nopea kieliopin tarkistus: Suorittaa nopean kieliopin tarkistuksen.
  • Arvaa sulkematta jäänyt lohko: Antaa editorin lopettaa suljettu lohko, kuten puuttuva "End" käytettäessä "If" lausetta.
  • Arvaa väärinsijoitettu IFDEF/ENDIF: Antaa editorin korjata puuttuva ehdollinen määrittely.
  • Liitä CVS-sana...: Liittää CVS-avainsanan, kuten "Author" tai "Date".
  • Liitä kenttiä: Liittää yleisiä arvoja kuten "GPL ilmoitus".
  • Lisää tiedoston koko nimi...: Valitaan tiedosto jonka nimi polkuineen lisätään.
  • Lisää ToDo-merkintä: Lisää ToDo-kommentin.
  • Käännösyksikön tietoja...: Näyttää tietoja käännösyksiköstä.
  • JEDI Code Format: Näyttää JEDI Code Format optiot projektista.

Projekti-valikko

ProjectMenu.jpg
  • Uusi projekti: Luo uuden projektin. Ponnahdusikkuna avautuu josta valitaan minkä tyyppinen projekti on.
  • Luo uusi projekti tiedostosta: Navigation valintaikkuna avautuu, sallien valita tiedoston, josta luodaan uusi projekti.
  • Avaa projekti Avaa projektin, joka on jo luotu ja tallennettu. Valintaikkuna näkyy luettelona kyseisen kansion Lazarus Project Information (.lpi) tiedostoja, joista projekti voidaan valita.
  • Avaa esillä ollut Projekti: Näyttää pop-up luettelon viimeaikaisista projekteista, joita on aikaisemmin avattu Lazaruksessa ja mahdollistaa valinta yhden näistä.
  • Sulje projekti Sulkee avoinna olevan projektin.
  • Tallenna projekti: Samanlainen kuin Tiedosto -> Tallenna: kaikki avoinna olevan projektin tiedostot tallennetaan; jos niitä ei ole aiemmin tallennettu, kysytään tiedostonimi - samanlailla kuin "Tallenna projekti nimellä..." .
  • Tallenna projekti nimellä...: Kysyy projektin tiedostonimeä jolla se tallennetaan . Oletuksena tiedostonimi on Project1.lpi, mutta olisi parempi valita sovellusta kuvaavampi tiedostonimi. Lazarus ei salli että käytettäisiin samaa nimeä projektin ja käännösyksikön tiedostoniminä (katso alla ).
  • Julkaise projekti...: Luo kopion koko projektista. Jos haluat lähettää jollekin vain lähdekoodin ja kääntäjän asetukset, tämä toiminto on ystäväsi. Normaali projektikansio sisältää paljon tietoa. Suurinta osaa siitä ei tarvitse julkaista: Tällä .lpi tiedosto sisältää istunnon tiedot (kuten kursorin asema ja suljettujen käännösyksikköjen kirjaimerkit) ja projektikansio sisältää paljon .ppu, .o tiedostoja ja ajettavan tiedoston. "Julkaise projektin" luomma lpi tiedosto sisältää vain perustietoa ja lähdekoodia sekä alikansioita. Dialogissa voidaan asettaa sulkevan poistosuodattimen ja sisältävän lisäyssuodattimen ja komennolla "komento jälkeen" voit pakata tuotoksen yhdeksi arkistotiedostoksi. Katso Lazarus IDE Työkalut
  • Project Inspector: Opens a pop-up dialog with a tree-like display of the files in the current project. Allows you to add, remove or open selected files, or change options of the project.
  • Project Options...: Opens a pop-up dialog window with tabs for setting options for Application (Title, Output Target file name), Forms (allowing you to select among the available forms, make them Auto-create at start of application) and Info (specifying whether editor information should be saved for closed files, or only for project files).
  • Units...: Opens a pop-up dialog window with a list of the unit files in the current project.Clicking with the mouse on a filename selects that file; click on Open to display that file in the Source Editor. Checking the Multi box allows several files to be selected simultaneously, and they will all be opened in the Source Editor (but only one at a time will be displayed). This Menu Option is rather like the Project -> Project Inspector option, but only displays the list of Unit files and allows them to be opened.
  • Forms...: Opens a pop-up dialog window with a list of the Forms in the current project, and allows the selection of one or more of them for display.
  • Compiler options ...: (Recently moved here from the Run Menu). Opens a multi-page tabbed window which allows configuration of the compiler. Tabs include Paths which allows definition of search paths for units, include files, libraries etc, as well as allowing choice of widget type for the forms (gtk, gnome, win32); Parsing which allows choice of rules for parsing source programs, Code which allows choice of optimisation for faster or smaller programs, choice of target processor, types of checks, heap size etc; Linking allowing choice of whether or how to use debugging, static or dynamic libraries, and whether to pass options through to the linker; Messages to define what type of messages should be generated during error conditions; Other which allows decision to use default configuration file (fpc.cfg) or some other file; Inherited which shows a tree structure diagram to indicate how options have been inherited from units already incorporated; Compilation which allows definition of commands to be executed before or after the compiler is launched and can allow use of Make files.
  • Add Editor File to Project: Add the file currently being edited to the Project
  • Remove from Project: Gives a pop-up menu of files available for removal from project.
  • Units...: View a list of all the units in the project.
  • Forms...: View a list of all the forms in the project.
  • View Project Source: No matter which file you are editing, takes you back to the main program file (.lpr)or the main .pas file if there is no .lpr.

The Run Menu

RunMenu.jpg
  • Compile: Compiles all the files in the project.
  • Build: Builds all files in the project.
  • Quick Compile: Compiles the files in the project that have changed.
  • Clean up Build Files: Cleans up the build files in the project.
  • Abort build: Stop the build process once it is running - either you have remembered that you did something silly and want to stop the build, or the system seems to be taking far too long and something is obviously wrong.
  • Run: This is the usual way to launch the compiler and, if compilation is successful, to start execution of the application. What actually happens is that Lazarus saves a copy of your files, then starts the compiler and linker, then begins execution of the final linked binary program.
  • Pause: Suspend execution of the currently running program. This may allow you to inspect any output that has been generated; execution may be resumed by selecting Run again.
  • Show Execution Point: Shows the current execution point.
  • Step Into: Used in conjunction with the debugger, causes execution of the program one step at a time up to a bookmarked point in the source.
  • Step Over: Causes stepwise execution up to the statement marked, then skips the marked statement, and continues execution at normal speed. Useful in trying to isolate a statement that introduces a logical error.
  • Step Out: Step out of the current code block.
  • Run to cursor: Causes execution at normal speed (ie NOT one statement at a time) until either the statement is reached where the cursor is located or the current procedure is exited; then stops. Does not stop, if location is reached during recursion. Resume execution at normal speed by selecting Run.
  • Stop: Cease execution of the running program. Cannot be resumed by selecting Run; this will start the program again from the beginning (re-compiling if necessary).
  • Run Parameters: Opens a multi-page pop-up window which allows command-line options and parameters to be passed to the program to be executed; allows selection of display to run program (eg a remote X terminal may be used in Linux); some system Environment variables may be overridden.
One very important use of this sub-menu is to activate a terminal window in which conventional Pascal console input/output is displayed. If you are developing a console-mode Pascal program (ie one that doesn't use the Graphical User Interface with its forms, buttons and boxes) then you should check the box for "Use launching application". The first time you do this and try the Compile/Run sequence, you will probably get a rude message to say
"xterm: Can't execvp /usr/share/lazarus//tools/runwait.sh: Permission denied".  
If this happens, you need to change the permissions on the appropriate file (for example using chmod +x filename, or using the Windows utility for changing permissions); you might have to do this as root. After this, each time you launch you program, a console box will appear and all your text i/o (readln, writeln etc) will appear in it.
After your program has finished execution, a message "Press enter" appears on the screen. Thus any output your program generated will remain on the screen until you have had a chance to read it; after you press 'enter' the console window closes.
Note: as for the current version, there is no prepared console command for Windows users. Until the Lazarus team adressess that, the following line should work (on WinXP -- someone please update for other Windows versions).
C:\Windows\system32\cmd.exe /C ${TargetCmdLine}
See the separate tutorial on Console Mode Pascal programming.
  • Reset debugger: Restores the debugger to its original state, so that breakpoints and values of variables etc are forgotten.
  • Build file: Compile (build) just the file that is currently open in the Editor.
  • Run file: Compile, link and execute just the currently open file.
  • Configure Build + Run File: Opens a multi-page tabbed window with options to allow for build of just this file when Build Project is selected, allows selection of the working directory, the use of various Macros, etc. Then Builds and Runs the file.
These last three options enable you to open (and maintain) a test project. Use File -> Open to open an .lpr file, pressing cancel on the next dialog to open this file as "normal source" file.
  • Inspect...: Inspect a value when the program is paused.
  • Evaluate/Modify...: Evaluate or modify an expression or value when the program is paused.
  • Add Watch...: Add a variable to the watch list.
  • Add Breakpoint...: Add a breakpoint, which will will pause execution of the program at that line of code.

The Package Menu

PackageMenu.jpg
  • New Package...: Create a new package.
  • Open Loaded Package...: Open one of the files in the selected package.
  • Open Package File (.lpk)...: Displays a list of installed packages, with an invitation to open one or more of them, or to select various general or compiler options.
  • Open Package of Current Unit: Open the package for the unit currently in the editor.
  • Open Recent Package: Open a package that was opened recently.
  • Add Active File to Package...: Place the file (currently in the editor) into a package.
  • New Component: Create a new component.
  • Package Graph: Displays a showing the relationships of the packages currently being used (if you aren't using any other packages, the Lazarus package and the FCL and LCL will be displayed).
  • Install/Uninstall Packages...: Install or uninstall one or more packages.

The Tools Menu

ToolsMenu.jpg
  • Options...: View and changed the options and settings in the Lazarus IDE.
  • Re-scan FPC Source directory Looks through the directory again. Lazarus uses the fpc sources to generate correct event handlers and while looking for declarations. If somebody changes the directory in the environment options, then this directory is rescanned, to make sure Lazarus uses the version stored in that location. But if this directory has changed without Lazarus noticing, then you may get some errors when designing forms or doing "Find declaration". If you get such an error, you can do two things:
    1. Check the FPC source directory setting in the environment option.
    2. Re-scan FPC source directory.
  • Code Templates...: View the code templates that are available.
  • CodeTools Defines Editor...: Edit the code templates.
  • Project templates options...: Set the options for the project templates.
  • Configure external tools: Allows the user to add various external tools (usually macros) to the toolkit
  • Example Projects...: View the example projects that are available.
  • Diff: Allows comparison between two files (or, usually, two versions of the same file) to find differences. Options to ignore white space at beginning or end of lines or differences in line termination: CR+LF versus LF). Useful for checking if there have been changes since last CVS update etc.
  • Leak View: View the heap trace output.
  • Check LFM File in Editor: Allows inspection of the LFM file which contains the settings that describe the current form
  • Convert Delphi Unit to Lazarus Unit: Helps in porting Delphi applications to Lazarus; makes the necessary changes to the source file. See Lazarus For Delphi Users and Code Conversion Guide.
  • Convert Delphi Project to Lazarus Project: For porting from Delphi to Lazarus: converts a Delphi project to Lazarus.
  • Convert Delphi Package to Lazarus Package: For porting from Delphi to Lazarus: converts a Delphi package to Lazarus.
  • Convert DFM file to LFM: For porting from Delphi to Lazarus: converts the Form Description files from Delphi to Lazarus.
  • Convert Encoding of Projects/Packages...:
  • Build Lazarus with Profile: Normal IDE: Launches a re-build of Lazarus from the most recently downloaded or updated SVN files. Hit the button and sit back to watch it happen! (track the process on your Messages window).
  • Configure "Build Lazarus": Allows the user to determine which parts of Lazarus should be re-built, and how. For example, you could select to have just the LCL re-built, or to have everything except the examples built; you can select which LCL interface to use (ie which set of widgets), and you can select the target operating system and specify a different target directory.

The Windows Menu

WindowMenu.jpg

Contains a list of the currently opened files and the available windows such as Source Editor, Object Inspector and Project Inspector. Clicking on the name of one of the windows brings it to the foreground and gives it focus.

The Help Menu

HelpMenu.jpg

At present this has three selections:

  • Online Help which at present opens a browser window that contains a picture of the running cheetah and a few links to the Lazarus, Free Pascal and Wiki websites
  • Reporting a bug opens the wiki page, which describe the bug reporting procedure
  • Configure Help which opens a pop-up menu with options to select viewers and databases from which to read Help information. This option allows the user to specify either the on-line documents section of the Lazarus-CCR website, some other website containing the documents, or a local store for the documentation (this would eventually become the default, when the Help system is fully developed).

At present by default, if you place your Editor cursor over any keyword from the Free Pascal Components Library FCL, the RunTime Library RTL or the Lazarus Components Library LCL, and then press F1 you will be taken by your default browser to the appropriate definition on the website. Be aware that your browser may be located on another desktop on your machine (eg in Linux), and you may not see the information immediately; of course if you are not connected to the internet you cannot get this information.

There are alternative help options which gives the end-user off-line help. For example, if you have a copy of Kylix, you can reuse the help files supplied with it, inside Lazarus IDE. See the Adding Kylix Help page for details.

  • About Lazarus Displays a pop-up box with some information about Lazarus.

Eventually there will be a full on-line Help service, with information about Pascal syntax, the use of the IDE, how to use, modify or create Components, and hints on how to perform certain tasks. This part of the Documentation section (the thing you are currently reading) represents the beginning of the process. We need contributions from anyone who feels able to provide them: the WiKi is very easy to edit.

The Button bar

A small toolbar area on the left of the main editor window, just below the Main Menu and to the left of the Component Palette, contains a set of buttons which replicate frequently-used Main Menu selections:

New unit, Open (with a down-arrow to display a drop-down list of recently used files), Save, Save all, New Form, Toggle Form/Unit (ie show either form or source code of Unit), View Units, View Forms, Run (ie compile and Run), Pause, Step Into, Step over (the last two are Debugger functions).

The Component Palette

A Tabbed toolbar which displays a large number of icons representing commonly used components for building Forms.

Each tab causes the display of a different set of icons, representing a functional group of components. The left-most icon in each tabbed group is an obliquely leftward-facing arrow, called the Selection Tool.

If you allow the mouse cursor to hover over any of the icons on the Component Palette, without clicking on the icon, the title of that component will pop-up. Note that each title begins with a 'T' - this signifies 'Type' or more accurately 'Class' of the component. When you select a component for inclusion in a form, the Class is added to the type section of the interface part of the Unit (usually as part of the overall TForm1), and an instance of that class is added to the var section (usually as the variable Form1). Any Methods that you design to be used by the Form or its Components (ie Procedures or Functions) will be placed in the implementation part of the Unit.

How To Use the Palette

To use the Palette, there must be an open form on view in the editor (if there isn't one, select File -> New Form). Click on the icon in the appropriate tab of the Palette for the component you want to use, then click on the Form, near where you want the component to appear. When the desired component appears, you can select it by clicking with the mouse. Once selected on the form, the object is also selected in the Object Inspector window, where you can edit its properties and events.

Adjustments to the visual appearance of an object can be made either by altering the picture itself on the Form using the mouse, or by changing the relevant Property in the Object Editor for that component.

If you install additional components, either those you have written yourself, or some coming as a package from some other source, then extra tabs with the relevant icons will appear in your Component Palette. These new components can be selected and used on your forms in the same way as those supplied by default.

In the following list of the Components, you will find links to files that contain descriptions of the Units in which they are found. If you want to find out about the properties of a particular component, it is often worth looking at the Inheritance of that component and then inspecting the properties of the base type from which it is derived. For example, to understand TMaskEdit it is also useful to examine TCustomMaskEdit.

Standard

(See Standard tab for components description)

Component Palette Standart.png
Frequently used components: TMainMenu, TPopupMenu, TButton, TLabel, TEdit, TMemo, TToggleBox, TCheckBox, TRadioButton, TListBox, TComboBox, TScrollBar, TGroupBox, TRadioGroup, TCheckGroup, TPanel, TActionList

Additional

(See Additional tab for components description)

Component Palette Additional.png
More, often-used components: TBitBtn, TSpeedButton, TStaticText, TImage, TShape, TBevel, TPaintBox, TNotebook, TLabeledEdit, TSplitter, TTrayIcon, TMaskEdit, TCheckListBox, TScrollBox, TApplicationProperties, TStringGrid, TDrawGrid, TPairSplitter, TColorBox, TColorListBox, TChart

Common Controls

(See Common Controls tab for components description)

Component Palette Common Controls.png
TTrackBar, TProgressBar, TTreeView, TListView, TStatusBar, TToolBar, TUpDown, TPageControl, TTabControl, THeaderControl, TImageList, TPopupNotifier

Dialogs

(See Dialogs tab for components description)

Component Palette Dialogs.png
TOpenDialog, TSaveDialog, TSelectDirectoryDialog, TColorDialog, TFontDialog, TFindDialog, TReplaceDialog, TOpenPictureDialog, TSavePictureDialog, TCalendarDialog, TCalculatorDialog, TPrinterSetupDialog, TPrintDialog, TPageSetupDialog

Several useful Dialog procedures or functions don't appear on the Palette, but are easily used as direct calls from your source program.

For several good examples of the use of Components see the $LazarusPath/lazarus/examples subdirectory of your source installation. Many of the programs show how to use dialogs and other components directly without using the IDE and component palette or having a separate form definition file: all the components are fully and explicitly defined in the main Pascal program. Other example programs make full use of the IDE.

Remember to open these examples as projects, with the .lpi file. Opening the .pas source code file and hitting RUN will just append this source file to whatever project you opened last.

Some examples don't work straight away: you may need to play about with paths and permissions of files or directories. If you want to compile any of the examples, make sure that you have read/write/execute permissions for the files and directories, or copy the files to a directory where you do have the appropriate permissions.

Try running the 'testall' program to see a menu of the available components together with small example test forms for most of them; then inspect the code to find out how they work!

Misc

Component Palette Misc.png
TColorButton, TSpinEdit, TFloatSpinEdit, TArrow, TCalendar, TEditButton, TFileNameEdit, TDirectoryEdit, TDateEdit, TCalcEdit, TFileListBox, TXMLPropStorage, TIniPropStorage, TBarChart, TButtonPanel, TIDEDialogLayoutStorage

Data Controls

Component Palette DataControls.png
Data-aware components, which largely replicate the Standard and Additional groups but are applicable to Databases: TDBNavigator, TDBText, TDBEdit, TDBMemo, TDBImage, TDBListBox, TDBComboBox, TDBCheckBox, TDBRadioGroup, TDBCalendar, TDBGroupBox, TDBGrid

Data Access

Component Palette DataAccess.png
TDatasource, TMemDataset, TSdfDataSet, TFixedFormatDataSet, TDbf

System

Component Palette System.png
TTimer, TIdleTimer, TLazComponentQueue, THtmlHelpDatabase, THtmlBrowserHelpViewer, TProcessUTF8, TAsyncProcess, TProcess, TSimpleIPCClient, TSimpleIPCServer, TXMLConfig, TEventLog

SynEdit

Component Palette SynEdit.png
SynEdit is an advanced multi-line edit control which is integrated into the Lazarus. It is the code editor of the Lazarus IDE and is available in the directory "lazarus/components/synedit". It supports syntax highlighting, code completion, code folding and includes exporters for HTML, tex and rtf.
TSynEdit, TSynAutoComplete, TSynExporterHTML, TSynMacroRecorder, TSynMemo, TSynPasSyn, TSynFreePascalSyn, TSynCppSyn, TSynJavaSyn, TSynPerlSyn, TSynHTMLSyn, TSynXMLSyn, TSynLFMSyn, TSynUNIXShellScriptSyn, TSynCssSyn, TSynPHPSyn, TSynTeXSyn, TSynSQLSyn, TSynPythonSyn, TSynVBSyn, TSynAnySyn, TSynMultiSyn

How to use Common Controls

The Units StdCtrls, ComCtrls and ExtCtrls contain definitions and descriptions of many of the most commonly used controls for constructing Forms and other Objects in Lazarus Applications.

Many of the final target controls that the application developer wants to use, such as TButton, TMemo, TScrollBar etc, have a corresponding ancestor class such as TCustomButton, TCustomMemo or TCustomScrollBar. Several of the properties and methods relevant to the final target control are defined (and explained) more fully in the TCustomXXX class, and are inherited by the final target control.

If you drop a component on the form editor you don't need to add code explicitly to create it. The component is automatically created by the IDE together with the form, and destroyed when the form is destroyed. However, if you create the component yourself by code don't forget to free it when it is no longer needed.

Ways to Set Properties

If you place a component on the Form Designer and look at the Object Inspector, you can observe the properties change as you move the component around.

For example, if you place a button (TButton) on the form, click on it to select it, then move it around the form with the mouse, you can watch the values of Top and Left change in the Object Inspector to reflect the new position. If you use the object's re-sizing bars to adjust its size, you can watch the Height and Width properties change as well.

On the other hand, by using the Object Inspector, you can select the value associated with a property such as height, and type in a new value; you can watch the size of the object on the form change to reflect the new value.

You can also explicitly change the properties of the object in code by typing (in the appropriate Implementation section of the Source editor), for example

Form1.Button1.Height := 48; If you type this new value into the Source Editor and then look back at the Form Designer, you will see that the button on the Form has taken the new size. The new value will also be shown in the Object Inspector.

In summary, there are usually about three different ways to determine each property of an object:

  • by using the mouse on the form,
  • by setting the values in the Object Inspector,
  • or explicitly by writing code in the editor.

Common Properties

The components defined in these Units have several properties that are common to most of them, and other properties that are specific to the individual components. We shall describe the most common ones here. Unusual or control-specific properties will be described for the individual controls.

Additional Help can always be obtained by selecting a property or keyword, in either the Object Inspector or the Source Editor, and pressing F1. You will be taken by your Help browser to the appropriate page in the documentation.

If the description of a property on that page is insufficient, you can navigate to the corresponding description in the ancestor classes, by selecting the links in the Inheritance listing or by selecting the ancestor Type in the declaration of the object.


Some commonly listed properties
PropertyMeaning
Action The main action or event associated with the object. For example selecting an 'Exit' Button might cause the 'Close' action
Align Defines the way in which an object is to be lined up with the parent object. Possible values are alTop (placed at the top and using the full available width), alBottom, alLeft (placed at the left and using the full available height), alRight. alNone (place anywhere on parent control) or alClient (takes all available space next to controls aligned to top, bottom, left or right)
Anchor Used to keep a control a certain distance from the defined edges of a parent control, when the parent is resized. For example [akBottom, akRight] will keep the control a fixed distance from the bottom right corner.
AutoSelect When True, an editing control will select all its text when it receives focus or when the Enter key is pressed.
AutoSelected True indicate that the edit or combobox control has just performed an AutoSelect operation so that subsequent mouse-clicks and keystrokes proceed normally without selecting the text.
BorderSpacing The space around the edge between an Anchored control and its parent.
Caption The text that is displayed on or near the control; it should preferably give some clue as to the function of the control, or an instruction such as 'Close' or 'Execute'. By default Caption is set to be the same as the 'Name' property, and the application programmer should substitute meaningful text instead of the default values.
CharCase Indicates how text is displayed in a text editing control: Normal (retaining the case of the letters typed by the user), converted to uppercase, or converted to lowercase
Constraints Sets the minimum and maximum sizes for a control. If a control is resized the new dimensions are always within the ranges given here. You should take care when setting these options that they do not conflict with the Anchors and Align settings.
Color The Colour to be used to draw the control or to write the text it contains.
Enabled A Boolean property to determine whether or not a control is capable of being selected and performing an action. If it is not Enabled, it is often Grayed out on the Form.
Font The Font to be used for writing the text associated with the control - either the caption or label, or the text-strings contained within the control. The entry on the Object Inspector usually has a (+) box on the left, and selecting this box reveals further options such as character set, colour and size.
Hint A short piece of informative pop-up text that appears if the mouse-cursor hovers over the control. See the ShowHint property.
Items The list of 'Things' that the object contains, such as a group of images, a series of lines of text, a number of actions in an actionlist, etc
Lines An array of strings, containing the textual data in controls with more than a single line of data, such as an Edit-Box or a Combo-Box. The array is zero-indexed, ie the lines are numbered [0..numLines-1]
Name The identifier by which the control is known in the program. The IDE gives it a default name based on the underlying type, for example successive instances of TBitButton would be named Form1.BitBitton1 and Form1.BitButton2; it is up to the application programmer to give them more meaningful names such as ExitButton or OKButton. By default the Name of the control is applied to the Caption for the control, but the text of the Caption may be changed separately.
PopUpMenu A window containing context-sensitive menu information that pops up when the right mouse button is clicked on the object.
Position (or Top, Left) Determines where the control is located on the parent form or window
ReadOnly Boolean property which, if True, signifies that the contents of the control can be read by the user or the calling routine, but cannot be written or changed.
ShowHint Allows a small window containing a context-sensitive Help or other description to be displayed when the mouse cursor 'hovers' over the control. See the Hint property.
Size (or Height and Width) The dimensions of the control
Style The options available for Style depend upon the sort of Control being considered: for instance the Style may be defined by TFormStyle, TBorderStyle, TButtonStyle etc.
TabOrder Integer defining where in the sequence of tabs on the Form this control is to lie
TabStop Boolean property which if True places this control in the sequence of objects that the user can reach by successively pressing the Tab key
Text The String of Text that represents the actual data that this control contains. Applies particularly to Text, Memo and StringList types of object. Most of the editing operations (such as Select, Clear, Cut, Copy) are performed in this part of the object, which holds the actual string being edited. If the control contains more than a single line of text, for example TMemo or TComboBox, then the textual elements are arranged as an array of strings (zero-indexed, ie numbered from [0..numLines-1]) in Lines.
Visible If true, the object can be seen on the Form; if False, object is hidden
WordWrap Logical flag to show whether or not word-wrap is enabled, ie if a word comes close to the end of a line and is going to be too long for the line, it is wrapped down to the next line.

Event Actions

Many actions are commonly listed in the 'Events' tab of the Object Inspector. If you select an entry in the list, a ComboBox appears with a DropDown list showing any actions that have aleady been defined, and allowing you to choose one to be associated with this event. Alternatively you can select the ellipsis (three dots ...) and you will be taken to an area of the Source Editor where you can begin typing your own action instructions for the selected event.

While a large number of events is available for any given control, in practice it is only necessary to populate a few of them. For most controls, it is sufficient to provide coding for 'OnClick'; for more complex controls it may be necessary also to provide for 'OnEntry' (when the mouse cursor enters the Control and gives it focus) and 'OnExit' (when the mouse cursor leaves the Control; or you may need to write an event handler for 'OnChange' or 'OnScroll', depending on the nature of the particular control with which you are dealing.

The pop-up menu that appears when you right-click an object in the Form Designer has, as its first item: 'Create default event' and selecting this option will have the same effect as selecting the ellipsis in the Object Inspector for the default event, usually OnClick: you are taken to the Implementation area of the Source Editor where you can type the code for the event handler.

A common strategy in Object-Oriented programming is to provide an ActionList with the facility for entering, removing or editing a number of pre-defined actions from which the most appropriate can be selected to use in any particular instance.


Some commonly listed Actions
Action Meaning
OnChange Action to be taken if any change is detected (eg mouse move, mouse click, key press, edit text, alter picture, etc)
OnClick Action to be taken when the (first, usually left) mouse button is clicked. This is commonly the main or default action of the control; for example clicking on a button or checkbox initiates the action associated with the checkbox. It may alternatively initate a process of selection, for instance in a TextBox or Memo, or signal the beginning of painting with a Pen or Brush.
Click A method to emulate in code the effect of clicking on a control. This method is most often found in Button-type controls (TButton, TBitBtn, TSpeedButton etc). A procedure can be written that calls the same code as the OnClick action. This facility can be particularly useful if the activation of one control by clicking causes a cascade of other controls to be activated, and the Click method can be used to initiate the action rather than having the user explicitly click on a lot of controls.
OnDragDrop Action to be taken during Drag-Drop manoeuvres, ie when the mouse is used to 'capture' an item or some text etc and move it around the screen to a new location.
OnEditingDone Action to be taken when the user has finished all edits/modifications to the control. This is often used to validate the control content (e.g. check if an entered text is a valid IP address)
OnEntry Action to be taken when the mouse cursor enters the area occupied by the object, usually transfering focus to that object. This might include changes in the appearance of the object such as highlighting or raising the border.
OnExit Action to be taken when the mouse moves out of the area of the object, usually transferring focus out of the object.
OnKeyPress Action to be taken for any key-press. Subtly different from OnKeyDown, which simply responds to a key being down, whether or not it was already down when focus was given to this control. OnKeyPress requires that a key becomes pressed while focus is in this control.
OnKeyDown Action to be taken if a key is down while focus is in this control. Subtly different from OnKeyPress - for example the key might already have been down when focus entered this control, whereas OnKeyPress requires the key to become pressed while focus is in the control.
OnKeyUp Action to be taken if a key is up (ie not pressed) while focus is in this control.
OnMouseMove Action to be taken if the mouse cursor moves while focus is in this control.
OnMouseDown Action to be taken if the mouse button is down while focus is in this control.
OnMouseUp Action to be taken if the mouse button is up while the cursor is over this control. Implies that the mouse button was previously down and has been released. The case where the cursor enters the control but the mouse button has not yet been pressed is covered by OnEntry or OnMouseEnter.
OnResize Action to be taken when the control is resized. Might include re-alignment of text or selection of a different font size etc.

Contructors & Destructors

These are two special methods associated with each control:

  • Constructors: such as Create allocate memory and system resources needed by the object. They also call the constructor of any sub-objects present in the class.
  • Destructors: remove the object and de-allocate memory and other resources. If you call Destroy for an object which hasn't being initialized yet it will generate an error. Always use the Free method to deallocate objects, because it checks whether an object's value is nil before invoking Destroy.

Take the following precautions when creating your own Destroy method:

  • Declare Destroy with the override directive, because it is a virtual method.
  • Always call 'inherited Destroy;' as the last thing on the destructor code.
  • Be aware that an exception may be raised on the constructor in case there is not enought memory to create an object, or something else goes wrong. If the exception is not handled inside the constructor, the object will be only partially built. In this case Destroy will be called when you weren't expecting it, so your destructor must check if the resources were really allocated before disposing of them.
  • Remember to call Free for all objects created on the constructor.

How to use Menu Controls

Hints for creating menus for your forms

TMainMenu is the Main Menu that appears at the top of most forms; form designers can customise by choosing various menu items. TPopupMenu is a menu window that pops up with pertinent, usually context-sensitive, details and choices when the right mouse button is clicked near a control

Main Menu is a non-visible component: that is, if the icon is selected from the Component Palette and placed on the form, it will not appear at runtime. Instead, a menu bar with a structure defined by the Menu Editor will appear. Popup menus (placed on the form by selecting the icon from the Component Palette) do not appear at all unless the right mouse button is clicked on a control that owns such a menu.

To see the Menu Editor, right-click on the Main Menu or Popup Menu icon on your Form. A pop-up box appears that invites you to enter items into the Menu bar.

An edit box is displayed, containing a button labelled "New Item1". If you right-click on that box, a pop-up menu is displayed that allows you to add a new item before or after (along the same level) or create a sub-menu with the opportunity to add further items below (or above) the new item in a downward column.

Any of the MenuItems that you add can be configured using the Object Inspector.

At the least you should give each item a Caption which will appear on the Menu Bar. The caption should indicate the activity to be selected, such as "File Open" or "Close", "Run" or "Quit". You may also wish to give it a more meaningful Name.

If you want a particular letter in the Caption to be associated with a shortcut key, that letter should be preceded by an ampersand (&). The Menu item at run-time will appear with the shortcut letter underlined, and hitting that letter key will have the same effect as selecting the menu item. Alternatively you can choose a shortcut key sequence (such as Ctrl+C for Copy or Ctrl+V for Paste - the standard keyboard shortcuts) with the ShortCut property of the MenuItem.

It is often helpful to use the Menu controls in conjunction with an ActionList which contains a series of standard or customised Actions. Menu Items can be linked in the Object Inspector to actions on the list, and the same actions can be linked to buttons, toolbar buttons, speedbuttons etc. It is obviously more efficient to re-use the same code to respond to the various events, rather than writing separate OnClick event handlers for each individual control.

By default, a number of standard actions are pre-loaded from StdActns or, if DataAware controls are used, from DBActns. These actions can be chosen using the ActionList editor which appears when you right-click on the ActionList icon on the Form Designer.

Virheenjäljitys

Still to be written.

1) Make sure you read the setup: Debugger_Setup

2) See also category: IDE Window - Debug

3) Read limitations: GDB_Debugger_Tips#Inspecting_data_types_.28Watch.2FHint.29 This page also helps with some platform/version specific issues

Lazarus tiedostot

   (Thanks to Kevin Whitefoot.)
   (Additions by Giuseppe Ridinò, User:Kirkpatc and Tom Lisjac)

When you save you will actually be saving two files:

  xxx.pas and yyy.lpr 

(You save more than that but those are the ones you get to name). The project file (lpr) and the unit file (pas) must not have the same name because Lazarus will helpfully rename the unit (inside the source code) to the same as the unit file name and the program to the name of the project file (it needs to do this or the compiler will probably not be able to find the unit later when referred to in the project file). Of course to be consistent it changes all the occurrences of unit1 to xxx.

So if you are saving a project called again, trying to save again.pas and again.lpr fails because unit names and program names are in the same name space resulting in a duplicate name error.

So here is what I ended up with:

e:/lazarus/kj/lazhello:

total 4740  free 76500
-rwxrwxrwx   1 kjwh     root  4618697 Mar 24 11:19 again.exe
-rw-rw-rw-   1 kjwh     root     3002 Mar 24 11:21 again.lpi
-rw-rw-rw-   1 kjwh     root      190 Mar 24 11:18 again.lpr
-rw-rw-rw-   1 kjwh     root      506 Mar 24 11:08 againu.lfm
-rw-rw-rw-   1 kjwh     root      679 Mar 24 11:08 againu.lrs
-rw-rw-rw-   1 kjwh     root      677 Mar 24 11:08 againu.pas
-rw-rw-rw-   1 kjwh     root     2124 Mar 24 11:08 againu.ppu
-rwxrwxrwx   1 kjwh     root      335 Mar 24 11:07 ppas.bat

Note that there are many more files than the two that I thought I was saving.

Here is a brief note about each file:

again.exe: The main program binary executable. Win32 adds an "exe" extension. Linux has none (just the name of the program). This file will be huge in Linux due to the inclusion of debugging symbols. Run the "strip" utility to remove them and substantially shrink the executable size.

again.lpi: (Lazarus Project Information). This is the main information file of a Lazarus project; the equivalent Delphi main file of an application will be the .dpr file. It is stored in an XML format and contains instructions about all the libraries and units required to build the executable file.

again.lpr: The main program source file or master file. Despite its Lazarus specific extension it is in fact a perfectly normal Pascal source file. It has a uses clause that lets the compiler find all the units it needs. Note that the program statement does not have to name the program the same as the file name. This file is usually fairly small, with just a few statements to initialise, build the forms, run and close the application. Most of the work is done in the unit source files, with suffix '.pas'

againu.lfm: This is where Lazarus stores the layout of the form unit, in human readable form. It reflects the properties of the various components, as set in the Object Inspector. Each object description starts with a line:

object xxxx 
  then there follows a list of properties 
  (including embedded or nested objects) then an 
end 

line. Lazarus uses this file to generate a resource file (.lrs) that is included in the initialisation section of the againu.pas unit. Delphi dfm files can be converted to lfm format in the Lazarus IDE using the Tools->Convert DFM file to LFM utility.

againu.lrs: This is the generated resource file which contains the instructions to the program for building the form (if you look in the main Unit file, you will see in the initialization section the line

{$i againu.lrs}

which instructs the program to load the resource file). Note that it is not a Windows resource file.

againu.pas: The unit that contains the code for the form; this is usually the only file that the application programmer needs to edit or inspect, and contains any code specifically supplied by the programmer (especially event handlers).

againu.ppu: This is the compiled unit which gets linked into the executable file together with any other units named in the Uses section.

ppas.bat: This is a simple script that links the program to produce the executable. If compilation is successful, it is deleted by the compiler.

See also