Sign in Join
FPDoc Onlineexperiment

AssignStr procedure

In unit sysutils

Assigns an ansistring to a null-terminated string.

Declaration

pascal
procedure AssignStr(var P: PString; const S: string)

Description

AssignStr allocates S to P. The old value of P is disposed of.

This function is provided for Delphi compatibility only. AnsiStrings are managed on the heap and should be preferred to the mechanism of dynamically allocated strings.

Errors

None.

See also

Example: ex63

pascal
Program Example63;

{ This program demonstrates the AssignStr function }
{$H+}

Uses sysutils;

Var P : PString;

Begin
 P:=NewStr('A first AnsiString');
 Writeln ('Before: P = "',P^,'"');
 AssignStr(P,'A Second ansistring');
 Writeln ('After : P = "',P^,'"');
 DisposeStr(P);
End.

An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.