Sign in Join
Wiki copytemporary

IDE Window: Code Templates/fi

Deutsch · English · Español · Français · Suomi

Luettelo kaikista kehitysympäristön ikkunoista

Mitä ovat koodilyhenteet?

Koodilyhenteet ovat lyhenteitä varsinaisesta koodista. Esimerkiksi: voit kirjoittaa 'cl' lähdekoodieditorissa ja painaa Ctrl+j näppäimiä yhtäaikaa jolloin kutsutaan 'cl' vastaavaa koodilyhennettä. Tämä ominaisuus säästää paljolta kirjoittamisen vaivalta.

Tämä ikkuna sallii muokata nykyisiä koodilyhenteitä tai lisätä omia.

The texts can contain macros. And you can add your own macros by creating a design time package and using the macrointf.pas of the IDEIntf package.

Example 1 - ifb

type

pascal
ifb|

The pipe should represent the cursor. Press Ctrl+j. It will be expanded to

pascal
if | then begin
pascal
end;

Again the pipe represents the cursor. You can see the cursor has moved as well.

This template is called 'ifb' and is defined as follows:

pascal
if | then begin
pascal
end;

This time the pipe '|' is a real character. It defines the cursor position after inserting the template.

Example 2 - Using macros

This example shows how to create a code template 'w' which inserts a line with the current procedure name.

 writeln(' ',|);

 writeln('$ProcedureName() ',|);

For instance:

 procedure TForm1.FormDestroy(Sender: TObject);
 begin
   w|
 end;

The pipe should represent here the blinking cursor, not a character.

 procedure TForm1.FormDestroy(Sender: TObject);
 begin
   writeln('TForm1.FormDestroy ',|);
 end;


From the Free Pascal wiki, page "IDE Window: Code Templates/fi", as it stood on 2006-10-15 after a change by Djzepi, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's Licensing page. If you have concerns about this material, message the admin.

Revision 1, last changed by WikiArchive .

Talk about this page

Nobody has opened a bench for this page yet. Sign in to open one.