unit Unit3;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, MPlayer, StdCtrls, Spin, ExtCtrls, SPComm;

type
  HMSRec = record
    Hours: byte;
    Minutes: byte;
    Seconds: byte;
    NotUsed: byte;
  end;
  Tsf = class(TForm)
    Button1: TButton;
    se: TSpinEdit;
    mp: TMediaPlayer;
    Timer1: TTimer;
    ListBox1: TListBox;
    Timer2: TTimer;
    Button2: TButton;
    Comm1: TComm;
    Comm2: TComm;
    Comm3: TComm;
    procedure Button1Click(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
    procedure Timer2Timer(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    procedure sf(n: Integer);
    { Public declarations }
  end;

var
  sf: Tsf;

implementation

{$R *.dfm}

procedure Tsf.Button1Click(Sender: TObject);
var
    num: Integer;
begin
    listbox1.Clear;
    listbox1.Items.Add('qd');
    listbox1.Items.Add('jf');
    num := StrToInt(se.Text);
    if num >= 1000 then
        num := num mod 1000;
    if num > 99 then
    begin
        listbox1.Items.add(IntToStr(num div 100));
        listbox1.Items.Add('bai');
    end;
    if (num mod 100) div 10 = 0 then   //shi wei shu 0
    begin
        if num mod 10 = 0 then      //ge wei shu 0
        begin
        end
        else if num > 99 then
            listbox1.Items.add('0');
    end else
    begin
        listBox1.Items.add(IntTOsTR((num mod 100) div 10));
        listbox1.Items.add('shi');
    end;
    if num mod 10 <> 0 then
    begin
        listbox1.Items.Add(IntToStr(num mod 10));
    end else
        if num = 0 then
            listbox1.Items.Add('0');
    listbox1.Items.Add('yuan');
    Timer1.Enabled := true;
end;

procedure Tsf.Timer1Timer(Sender: TObject);
begin
    Timer1.Enabled := false;
    if listbox1.Items.Count < 1 then
    begin
        Exit;
    end;
    try
        mp.FileName := 'D:\soft\yuyin\'+ listbox1.Items[0] + '.wav';
        listbox1.Items.Delete(0);
        mp.Open();
        mp.Play;
        Timer1.Interval := mp.Length;
    except
        ;
    end;
    //mp.Stop;
    Timer1.Enabled := true;
end;

procedure Tsf.Timer2Timer(Sender: TObject);
begin
    if listbox1.Items.Count = 0 then
    begin
        se.Value := se.Value + 1;
    end else
        exit;
    Sleep(200);
    button1.Click;
end;

procedure Tsf.Button2Click(Sender: TObject);
begin
    Timer2.Enabled := not Timer2.Enabled;
end;

procedure Tsf.sf(n: Integer);
var
    num: Integer;
begin
    listbox1.Clear;
    listbox1.Items.Add('qd');
    listbox1.Items.Add('jf');
    num := n;
    if num >= 1000 then
        num := num mod 1000;
    if num > 99 then
    begin
        listbox1.Items.add(IntToStr(num div 100));
        listbox1.Items.Add('bai');
    end;
    if (num mod 100) div 10 = 0 then   //shi wei shu 0
    begin
        if num mod 10 = 0 then      //ge wei shu 0
        begin
        end
        else if num > 99 then
            listbox1.Items.add('0');
    end else
    begin
        listBox1.Items.add(IntTOsTR((num mod 100) div 10));
        listbox1.Items.add('shi');
    end;
    if num mod 10 <> 0 then
    begin
        listbox1.Items.Add(IntToStr(num mod 10));
    end else
        if num = 0 then
            listbox1.Items.Add('0');
    listbox1.Items.Add('yuan');
    Timer1.Enabled := true;
end;

end.
