Unit 'EXEC' Package
[Overview][Constants][Types][Procedures and functions][Variables][Index] [#amunits]

FindPort

Find a system message port by name

Declaration

Source position: exec.pas line 1234

function FindPort(

  const name: pCHAR

):pMsgPort;

function FindPort(

  const name: string

):pMsgPort;

Arguments

name

  

Name of the message port to find.

Function result

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

Arguments

name

  

Name of the message port to find.

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