String → Array

Материал из DRKB

String --> Array[править | править код]

procedure AssignFixedString(var FixedStr: array of Char; const S: String);
var
  maxlen: Integer;
begin
  maxlen := Succ(High(FixedStr) - Low(FixedStr));
  FillChar(FixedStr, maxlen, ' '); { blank fixed string }
  if Length(S) > maxlen then
    Move(S[1], FixedStr, maxlen)
  else
    Move(S[1], FixedStr, Length(S));
end;


ID: 00253



function StrToArrays(str, r: string; out Temp: TStrings): Boolean;
var
  j: integer;
begin
  if temp <> nil then
  begin
    temp.Clear;
    while str <> '' do
    begin
      j := Pos(r,str);
      if j = 0 then
        j := Length(str) + 1;
      temp.Add(Copy(Str,1,j-1));
      Delete(Str,1,j+length(r)-1);
    end;
    Result := True;
  end
  else
    Result := False;
end;


Source: http://delphiworld.narod.ru
ID: 00796