Difference between revisions of "Source Examples"

From Freepascal Amiga wiki
Jump to navigation Jump to search
(Added hello world example program (as in wiki-editor trying to get the hang on things))
(MUI Helper link added)
 
(4 intermediate revisions by 3 users not shown)
Line 3: Line 3:
 
On this page Source example are going to collect (or links to it) which working on AROS freepascal
 
On this page Source example are going to collect (or links to it) which working on AROS freepascal
 
----
 
----
 +
==== Examples with own pages ====
 
* [[Call Library]] - How to call a library function
 
* [[Call Library]] - How to call a library function
 +
* [[MUI Helper]] - How to write MUI/Zune application like in C using muihelper
 
* ...
 
* ...
 
----
 
----
Basic hello world program:
 
<code>
 
  Program HelloWorld;
 
  Begin
 
    Writeln('Hello World');
 
  End.
 
</code>
 
  
 +
==== Hello World ====
 +
<source lang="pascal">
 +
Program HelloWorld;
 +
Begin
 +
  Writeln('Hello World');
 +
End.
 +
</source>
  
One example, Put a message to a named port:
+
==== Started from Workbench/Wanderer ====
<code>
+
How to check if the program started from Wanderer/Workbench
 +
<source lang="pascal">
 +
  program WBStart;
 +
  begin
 +
    if assigned(AOS_WbMsg) then
 +
      writeln('Started from WB')
 +
    else
 +
      writeln('Started from CLI');
 +
  end.
 +
</source>
 +
 
 +
==== Put a message to a named port ====
 +
 
 +
<source lang="pascal">
 
  function SafePutToPort(Msg: PMessage; Portname: string): Integer;
 
  function SafePutToPort(Msg: PMessage; Portname: string): Integer;
 
  var
 
  var
Line 33: Line 48:
 
   Permit();
 
   Permit();
 
  end;
 
  end;
</code>
+
</source>

Latest revision as of 17:29, 18 December 2016

Source Examples

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


Examples with own pages

  • Call Library - How to call a library function
  • MUI Helper - How to write MUI/Zune application like in C using muihelper
  • ...

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;