大家帮忙翻译一下:c++的一个函数→delphi

chengangcsdn 2005-03-10 11:02:12
void __fastcall TForm1::Button3Click(TObject *Sender)
{
unsigned char Buffer[100];
unsigned char Card_Type[2];
bool ct;
char temp[50];
unsigned char Card;
int mv;
if(!comopen) goto endss;
ct=!(ComboBox1->Text.SubString(1,2)=="23"||ComboBox1->Text.SubString(1,2)=="24");
if( ct||Edit2->Text.Length()!=8||Edit3->Text.Length()!=6||
Edit4->Text.Length()!=20||Edit5->Text.Length()!=6)
Application->MessageBoxA("检查输入是否正确!","Error",MB_OK);
else
{
strcpy(Card_Type,(ComboBox1->Text.SubString(1,2)).c_str());
strcpy(Buffer,(Edit2->Text.SubString(1,8)).c_str());
strcat(Buffer,(Edit3->Text.SubString(1,6)).c_str());
strcat(Buffer,(Edit4->Text.SubString(1,20)).c_str());
strcat(Buffer,(Edit5->Text.SubString(1,6)).c_str());
strcat(Buffer,"0000000000000000000000000000000000");
if(RadioButton3->Checked==1)
Card=0;
else
Card=7;
mv=write_card(Card,Card_Type,Buffer);
if(mv!=0)
{
sprintf(temp," 写卡失败!返回值为:%d",mv);
Application->MessageBoxA(temp,"错误!", MB_OK);
}
else
Application->MessageBox("写卡成功!","成功!",MB_OK);
return;
}
endss:
Application->MessageBox("请打开串口","错误",MB_OK);
}
...全文
51 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
chengangcsdn 2005-03-10
  • 打赏
  • 举报
回复
我没有试,如果还有什么不明白。再问你。
chengangcsdn 2005-03-10
  • 打赏
  • 举报
回复
呵呵!
不是我写的代码!
我是做酒店系统的。
这是给酒店做门锁的厂商,提供的接口函数!
谢谢了哈!
这就结贴!
beyondtkl 2005-03-10
  • 打赏
  • 举报
回复
procedure TForm1.Button1Click(Sender: TObject);
var
Buffer: array[0..99] of byte;
Card_Type: array[0..1] of byte;
ct: Boolean;
//temp: array[0..49] of Char;
temp: string;
Card: byte;
mv: Integer;
comopen: Boolean;
label endss;
begin
if not comopen then
goto endss;

ct := not ( (Copy(ComboBox1.Text,1,2) = '23') or (Copy(ComboBox1.Text,1,2) = '24'));

if( ct or (Length(Edit2.Text) <> 8) or (Length(Edit3.Text) <> 6)
or (Length(Edit4.Text) <> 20) or (Length(Edit5.Text) <> 6)) then
Application.MessageBox('','Error',MB_OK)
else
begin
strcopy(@Card_Type, PChar(Copy(ComboBox1.Text,1,2)));
strcopy(@Buffer, PChar(Copy(Edit2.Text, 1,8)));
strcat(@Buffer, PChar(Copy(Edit3.Text, 1,6)));
strcat(@Buffer, PChar(Copy(Edit4.Text, 1,20)));
strcat(@Buffer, PChar(Copy(Edit5.Text, 1,6)));
strcat(@Buffer, PChar('0000000000000000000000000000000000'));

if RadioButton1.Checked then
Card := 0
else
Card := 7;

mv := write_card(Card,Card_Type,Buffer);
if (mv <> 0)
begin
temp := Format('%d', mv);
Application.MessageBoxA(temp,'', MB_OK);
end
else
Application.MessageBox('','',MB_OK);
return;
end;


endss:
Application.MessageBox('err','err',MB_OK);
end;

whose code , it's bad...
chengangcsdn 2005-03-10
  • 打赏
  • 举报
回复
大家帮帮忙啊!真的急用啊!
chengangcsdn 2005-03-10
  • 打赏
  • 举报
回复
不懂!
beyondtkl 2005-03-10
  • 打赏
  • 举报
回复
bcb denghui

16,748

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 语言基础/算法/系统设计
社区管理员
  • 语言基础/算法/系统设计社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧