kolibrios/programs/develop/fp/examples/example.pp
bw 63328e8522 [FP] changes in RTL, first example
git-svn-id: svn://kolibrios.org@623 a494cfbc-eb01-0410-851d-a64ba20cac60
2007-09-12 16:34:21 +00:00

100 lines
2.6 KiB
ObjectPascal
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

{$codepage cp866}
{$mode objfpc}
{$smartlink on}
{$apptype console}
{ <20>  ¤ ­­ë© ¬®¬¥­â à áᬠâਢ ¥âáï ¢ë¯®«­¥­¨¥ ¯à¨«®¤¥­¨ï ⮫쪮 ª ª ª®­á®«ì­®¥,
â.¥. ¤¨à¥ªâ¨¢  concole ®¡ï§ â¥«ì­ , ¯®¢¥¤¥­¨¥ ¯à®£à ¬¬ë ¯à¨ ®âáãâá⢨¨ í⮩
¤¨à¥ªâ¨¢ë ¯à¥¤®¯à¥¤¥«¨âì ­¥«ì§ï. ƒ à ­â¨à®¢ ­­® ­¥«ì§ï ¨á¯®«ì§®¢ âì ä㭪樨
Write, WriteLn, Read, ReadLn ®â­®á¨â¥«ì­® áâ ­¤ àâ­®© ª®­á®«¨ ¢¢®¤ /¢ë¢®¤ .
}
program Example;
{ ‚ᥠä㭪樨 ¨¬¥î騥 ¢ ᢮¥¬ ¨¬¥­¨ ¯à¥ä¨ªá 'kos_' ïîâáï ¯« âä®à¬®§ ¢¨á¨¬ë¬¨
¨ ॠ«¨§®¢ ­ë ⮫쪮 ¯®¤ KolibriOS. ˆå ¨á¯®«ì§®¢ ­¨¥ ¢ «î¡ëå ¯à®£à ¬¬­ëå
¯à¨«®¦¥­¨ïå ª â¥£®à¨ç¥áª¨ ­¥ ४®¬¥­¤®¢ ­®, ¢ë­®á¨â¥ ¢á¥ ¬¥â®¤ë, ¨á¯®«ì§ãî騥
í⨠ä㭪樨, ¢ ®â¤¥«ì­ë¥ ¬®¤ã«¨ (¨ ¨á¯®«ì§ã©â¥ ­¥®¡å®¤¨¬ë¥  ¡áâࠪ樨).
}
procedure DoPaint;
{ ‚뢮¤ ᮤ¥à¦¨¬®£® ®ª­  ¯à¨«®¦¥­¨ï }
begin
kos_begindraw();
{®¯à¥¤¥«¥­¨¥ ¯ à ¬¥â஢ ®ª­  (0)}
kos_definewindow(200, 200, 200, 50, $23AABBCC);
{kos_definewindow ­¥ ¨¬¥¥â ¯ à ¬¥âà  ¤«ï ¢ë¢®¤  § £®«®¢ª ,
¤¥« ¥¬ íâ® ®â¤¥«ì­®© ä㭪樥©}
{kos_setcaption, ®â®¡à ¦¥­¨¥ § £®«®¢ª  ®ª­  (71.1)}
kos_setcaption('<27><>ˆŒ…<C592> <20><>Žƒ<C5BD>€ŒŒ');
{¢ë¢®¤ á®®¡é¥­¨ï (4)}
kos_drawtext(3, 8, '<27> ¦¬¨â¥ «î¡ãî ª« ¢¨èã...');
kos_enddraw();
end;
procedure DoKey;
{ Ž¡à ¡®âª  ᮡëâ¨ï ­ ¦ â¨ï ª« ¢¨è¨ }
var
Key: DWord;
Notes: array[0..3] of Byte;
begin
Key := kos_getkey();
{­ áâà ¨¢ ¥¬ ¡ãä¥à ¤«ï ­®â}
Notes[0] := $90;
Notes[1] := Key shr 8;
Notes[2] := $00;
{¢®á¯à®¨§¢®¤¨¬}
kos_speak(@Notes);
end;
function DoButton: Boolean;
{ Ž¡à ¡®âª  ᮡëâ¨ï ­ ¦ â¨ï ª­®¯ª¨ GUI }
var
Button: DWord;
begin
{¯®«ãç¨âì ª®¤ ­ ¦ â®© ª«¨ë¨è¨}
Button := kos_getbutton();
{¥á«¨ X, â® § ¢¥à襭¨¥ ¯à¨«®¦¥­¨ï}
Result := Button = 1;
end;
function ProcessMessage: Boolean;
{ @return: ‚®§¢à é ¥â False, ¥á«¨ ¡ë«® ᮡë⨥ ª § ¢¥à襭¨î ¯à¨«®¦¥­¨ï.
@rtype: True ¨«¨ False }
var
Event: DWord;
begin
Result := False;
{®¦¨¤ ¥¬ ᮡëâ¨ï ®â á¨á⥬ë}
Event := kos_getevent();
case Event of
SE_PAINT : DoPaint; {¯¥à¥à¨á®¢ª  ®ª­ }
SE_KEYBOARD: DoKey; {ᮡë⨥ ®â ª« ¢¨ âãàë}
SE_BUTTON : Result := DoButton; {ᮡ먥 ®â ª­®¯ª¨, ¬®¦¥â ®¯à¥¤¥«¨âì
§ ¢¥à襭¨¥ ¯à¨«®¦¥­¨ï, ¥á«¨ ¢¥à­¥â True}
end;
end;
procedure MainLoop;
{ ƒ« ¢­ë© 横« ¯à¨«®¦¥­¨ï }
var
ThreadSlot: TThreadSlot;
begin
{ᤥ« âì íâ® ®ª­®  ªâ¨¢­ë¬}
ThreadSlot := kos_getthreadslot(ThreadID);
kos_setactivewindow(ThreadSlot);
{­ áâà ¨¢ ¥¬ ᮡëâ¨ï, ª®â®àë¥ ¬ë £®â®¢ë ®¡à ¡ â뢠âì}
kos_maskevents(ME_PAINT or ME_KEYBOARD or ME_BUTTON);
{£« ¢­ë© 横«}
while not ProcessMessage do;
end;
begin
WriteLn('Look for a new window, I''m just a konsole, hi mike ;-)');
MainLoop;
end.