Unit 'Exec' Package
[Overview][Constants][Types][Procedures and functions][Variables][Index] [#aros]

FindPort

Find a system message port by name

Declaration

Source position: exec.pas line 1276

function FindPort(

  const Name: PChar

):PMsgPort;

Arguments

Name

  

Name of the message port to find.

Function result

A pointer to the message port, or nil if not found.

Description

This function will search the system message port list for a port with the given name. The first port matching this name will be returned. No arbitration of the port list is done. This function must be protected with A Forbid()/Permit() pair!

Example

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;

Documentation generated on: 2021-07-30