J
jihaiming
Unregistered / Unconfirmed
GUEST, unregistred user!
procedure TForm1.playmsg(channelno: integer);
var
i,code:integer;
begin
case channel[channelno].step of
0: begin
startplayfile(channelno,'voc/welcome.pcm',0);
showgrid.Cells[2,channelno+1]:='摘机';
showgrid.Cells[3,channelno+1]:='欢迎致电东进公司…………';
channel[channelno].step:=1;
end;
1:begin
if checkplayend(channelno) then
begin
stopplayfile(channelno);
startrecordfile(channelno,pchar(inttostr(channelno)+'.pcm'),8000*60);//预设置录音长度为1分钟
initdtmfbuf(channelno);
channel[channelno].step:=2;
showgrid.Cells[3,channelno+1]:='开始录音';
end
end;
2:begin
code:=getdtmfcode(channelno);
if code=12 then
begin
stoprecordfile(channelno);
startplayfile(channelno,'voc/end1.pcm',0);
showgrid.Cells[3,channelno+1]:='重播留言';
channel[channelno].step:=3;
exit;
end;
if checkrecordend(channelno) then
begin
stoprecordfile(channelno);
showgrid.Cells[3,channelno+1]:='重播留言';
startplayfile(channelno,'voc/end2.pcm',0);
channel[channelno].step:=3;
end ;
end;
3:begin
if checkplayend(channelno) then
begin
cutpcm(trim(inttostr(channelno)+'.pcm'),3000)
//直接去掉末尾3000左右的声音,把最后按键声音去掉
startplayfile(channelno,pchar(inttostr(channelno)+'.pcm'),0);
channel[channelno].step:=4;
end
end;
4:begin
if checkplayend(channelno) then
begin
startplayfile(channelno,'voc/byebye.pcm',0);
channel[channelno].step:=5;
end
end;
5:begin
if checkplayend(channelno) then
begin
resetchannel(channelno);
end
end;
end;
end;
嗯,case语句应该是选择性的吧.不过看这段程序好像是那种Goto语句似的. 在这个源程序中有Timer组件.其中调用这个函数. 但如果靠Timer 组件调用是否很麻烦啊?还是Case 语句有跳转的功能呢? 高手回答!!!!
var
i,code:integer;
begin
case channel[channelno].step of
0: begin
startplayfile(channelno,'voc/welcome.pcm',0);
showgrid.Cells[2,channelno+1]:='摘机';
showgrid.Cells[3,channelno+1]:='欢迎致电东进公司…………';
channel[channelno].step:=1;
end;
1:begin
if checkplayend(channelno) then
begin
stopplayfile(channelno);
startrecordfile(channelno,pchar(inttostr(channelno)+'.pcm'),8000*60);//预设置录音长度为1分钟
initdtmfbuf(channelno);
channel[channelno].step:=2;
showgrid.Cells[3,channelno+1]:='开始录音';
end
end;
2:begin
code:=getdtmfcode(channelno);
if code=12 then
begin
stoprecordfile(channelno);
startplayfile(channelno,'voc/end1.pcm',0);
showgrid.Cells[3,channelno+1]:='重播留言';
channel[channelno].step:=3;
exit;
end;
if checkrecordend(channelno) then
begin
stoprecordfile(channelno);
showgrid.Cells[3,channelno+1]:='重播留言';
startplayfile(channelno,'voc/end2.pcm',0);
channel[channelno].step:=3;
end ;
end;
3:begin
if checkplayend(channelno) then
begin
cutpcm(trim(inttostr(channelno)+'.pcm'),3000)
//直接去掉末尾3000左右的声音,把最后按键声音去掉
startplayfile(channelno,pchar(inttostr(channelno)+'.pcm'),0);
channel[channelno].step:=4;
end
end;
4:begin
if checkplayend(channelno) then
begin
startplayfile(channelno,'voc/byebye.pcm',0);
channel[channelno].step:=5;
end
end;
5:begin
if checkplayend(channelno) then
begin
resetchannel(channelno);
end
end;
end;
end;
嗯,case语句应该是选择性的吧.不过看这段程序好像是那种Goto语句似的. 在这个源程序中有Timer组件.其中调用这个函数. 但如果靠Timer 组件调用是否很麻烦啊?还是Case 语句有跳转的功能呢? 高手回答!!!!