Skocz do zawartości

[Delphi] funkcja read write w klasie np. Strings.Text


Integer

Polecane posty

Witam ponownie, tym razem coś bardziej prymitywnego, chociaż dla mnie to spora górka.

 

Może pokaże to na jakiejś prostej klasie, jakoś tak mam że na konkretach łatwiej mi idzie załapać smile.gif,

ja wiem że sa klasy TStringList i TStrings, ale to tylko przykład, a do konkretnych celów takie proste i małe w zupełności wystarczą.

I chyba znalazłem odpowiedź na moje pytanie tyle ze chyba tylko w odniesieniu do Stringa, bo czy w ten sam sposób można przekazywać zamiast Stringa np dynamiczne tabele danych z rekorami np. array of rekord_osoba?

 

 

 

 unit MListyTekstowe;

interface
Uses
 MSys,
 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
 Dialogs, ExtDlgs, XPMan, Menus, ExtCtrls;

type
 TPlikTxt = TextFile;

 PArrStr =^TArrStr ;
 TArrStr = array of String;

 // -----------------------------------------------------------------------
 TMultiTxt = class
 private
 public
max, cnt: Integer;
arrs: TArrStr;
function TextWyslij: string;
procedure LoadTextFromFileName(const _ScFileName: String; _TrimOK: Boolean;
                _NoBlankLinesOK: Boolean);
procedure Add(const S: String);
constructor Create();
destructor  Destroy(); override;
 end;


implementation


{ TLstStr  --------------------------------------------------------- }

constructor TMultiTxt.Create();
begin
  max:= -1;
  cnt:= 0;
  SetLength( arrs, cnt );
end;

destructor TMultiTxt.Destroy();
begin
  SetLength( arrs, 0 );
end;

procedure TMultiTxt.Add(const S: String);
begin
  Inc(max);
  Inc(cnt);
  SetLength( arrs, cnt );
  arrs[max]:= S;
end;

function  TMultiTxt.TextWyslij: String;
var i: Integer;
begin
  Result:= '';
  if max=-1 then Exit;      // pustka
  if max=0 then begin   // tylko jedna linia
     Result:= arrs[0];
     Exit;
  end;

  Result:= arrs[max];   // dodawaie od tylu ale kolejnosc zachowana
  for i:= max-1 downto 0 do begin
     Result:= arrs[i] +#13+#10+ Result;
     // frmGlow.Memo.Lines.Add(arrs[i]);
  end;
end;

Link do komentarza
Udostępnij na innych stronach

Zarchiwizowany

Ten temat jest archiwizowany i nie można dodawać nowych odpowiedzi.

×
×
  • Utwórz nowe...