[Overview][Constants][Types][Procedures and functions][Variables] Reference for unit 'oldlinux' (#rtl)

StringToPPChar

Split string in list of null-terminated strings

Declaration

Source position: line 0

function StringToPPChar(

  var S: String

):ppchar;

function StringToPPChar(

  var S: AnsiString

):ppchar;

function StringToPPChar(

  S: Pchar

):ppchar;

Description

StringToPPCharsplits the string Sin words, replacing any whitespace with zero characters. It returns a pointer to an array of pchars that point to the first letters of the words in S. This array is terminated by a Nilpointer.

The function does notadd a zero character to the end of the string unless it ends on whitespace.

The function reserves memory on the heap to store the array of PChar; The caller is responsible for freeing this memory.

This function can be called to create arguments for the various Execcalls.

Errors

None.

See also

CreateShellArgV

  

Create an array of null-terminated strings

Execve

  

Execute process using environment

Execv

  

Execute process

Example

Program Example70;

{ Program to demonstrate the StringToPPchar function. }

Uses oldlinux;

Var S : String;
    P : PPChar;
    I : longint;

begin
  // remark whitespace at end.
  S:='This is a string with words. ';
  P:=StringToPPChar(S);
  I:=0;
  While P[i]<>Nil do
    begin
    Writeln('Word ',i,' : ',P[i]);
    Inc(I);
    end;
  FreeMem(P,i*SizeOf(Pchar));
end.