Source Examples

From Freepascal Amiga wiki
Revision as of 22:41, 20 November 2013 by Alb42 (talk | contribs) (typing error)
Jump to navigation Jump to search

Source Examples

On this page Source example are going to collect (or links to it) which working on AROS freepascal


Examples with own pages


Hello World

Program HelloWorld;
Begin
  Writeln('Hello World');
End.

Started from Workbench/Wanderer

How to check if the program started from Wanderer/Workbench

  program WBStart;
  begin
    if assigned(AOS_WbMsg) then
      writeln('Started from WB')
    else
      writeln('Started from CLI');
  end.

Put a message to a named port

 function SafePutToPort(Msg: PMessage; Portname: string): Integer;
 var
   Port: PMsgPort;
   PName: PChar;
 begin
   Result := -1;
   PName := PChar(Portname + #0);
   Forbid();
   Port := FindPort(PName);
   if Assigned(Port) then
   begin
     PutMsg(Port, Msg);
     Result := 0;
   end;
   Permit();
 end;