unit Unit1;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
  Buttons, Spin, ShlepsUtils;

type

  { TForm1 }

  TForm1 = class(TForm)
    BufEdit: TEdit;
    GetLastTokenExSpeedButton: TSpeedButton;
    Label5: TLabel;
    MaskEdit: TEdit;
    GetNextTokenExSpeedButton: TSpeedButton;
    GetWordByNumberSpeedButton: TSpeedButton;
    GetValByNameSpeedButton: TSpeedButton;
    WordCountSpeedButton: TSpeedButton;
    WordNumberSpinEdit: TSpinEdit;
    TailEdit: TEdit;
    Label3: TLabel;
    Label4: TLabel;
    TokenEdit: TEdit;
    DelimEdit: TEdit;
    Label1: TLabel;
    Label2: TLabel;
    GetNextTokenSpeedButton: TSpeedButton;
    procedure GetLastTokenExSpeedButtonClick(Sender: TObject);
    procedure GetNextTokenExSpeedButtonClick(Sender: TObject);
    procedure GetNextTokenSpeedButtonClick(Sender: TObject);
    procedure GetValByNameSpeedButtonClick(Sender: TObject);
    procedure GetWordByNumberSpeedButtonClick(Sender: TObject);
    procedure WordCountSpeedButtonClick(Sender: TObject);
  private
    { private declarations }
  public
    { public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.lfm}

{ TForm1 }

procedure TForm1.GetNextTokenSpeedButtonClick(Sender: TObject);
Var Token,B,PB:String;
begin
   If TailEdit.Text<>'' Then B:=TailEdit.Text Else B:=BufEdit.Text;
   Token:=GetNextToken(B,PB,DelimEdit.Text);
   TokenEdit.Text:='"'+Token+'"';
   TailEdit.Text:=PB;
end;

procedure TForm1.GetNextTokenExSpeedButtonClick(Sender: TObject);
Var Token,B,PB:String;
begin
   If TailEdit.Text<>'' Then B:=TailEdit.Text Else B:=BufEdit.Text;
   Token:=GetNextTokenEx(B,PB,DelimEdit.Text);
   TokenEdit.Text:='"'+Token+'"';
   TailEdit.Text:=PB;
end;

procedure TForm1.GetLastTokenExSpeedButtonClick(Sender: TObject);
Var Token,B,PB:String;
begin
   If TailEdit.Text<>'' Then B:=TailEdit.Text Else B:=BufEdit.Text;
   Token:=GetLastTokenEx(B,PB,DelimEdit.Text);
   TokenEdit.Text:='"'+Token+'"';
   TailEdit.Text:=PB;
end;

procedure TForm1.GetWordByNumberSpeedButtonClick(Sender: TObject);
Var Token,B,PB:String;   Mask:Longint;
begin
   B:=BufEdit.Text;
   Token:=GetWordByNumber(B,WordNumberSpinEdit.Value,DelimEdit.Text,Mask);
   TokenEdit.Text:='"'+Token+'"';
   MaskEdit.Text:=IntToStr(Mask);
   TailEdit.Text:=PB;
end;

procedure TForm1.WordCountSpeedButtonClick(Sender: TObject);
begin
  Label5.Caption:=IntToStr(WordCount(BufEdit.Text,DelimEdit.Text));
end;

procedure TForm1.GetValByNameSpeedButtonClick(Sender: TObject);
Var Token,B,PB:String;
begin
   If TailEdit.Text<>'' Then B:=TailEdit.Text Else B:=BufEdit.Text;
   Token:=GetValByName(BufEdit.Text,DelimEdit.Text);
   TokenEdit.Text:='"'+Token+'"';
   TailEdit.Text:='';
end;


end.

