ddablib / envvars

Environment Variables Unit
1 stars 2 forks source link

Add `ToString` & `Size` functions to TPJEnvironmentVar #19

Open delphidabbler opened 2 years ago

delphidabbler commented 2 years ago

A common thing to do us to render an environment variable in name=value format. Add a ToString method to do this.

It is useful (eg when creating environment blocks) to know the size in chars of an environment variable in name=value format. So add a Size method to return the size in characters. (The size in bytes will be SizeOf(Char) * Size).

delphidabbler commented 2 years ago

Possible implementation details:

function TPJEnvironmentVar.ToString: string;
begin
  Result := fName + '=' + fValue;
end;

function TPJEnvironmentVar.Size: Integer;
begin
  Result := Length(ToString);
end;