请帮忙将这段c++ builder code 翻译成 delphi code

agangr 2003-08-22 09:04:14
//函数申明
int PlpOpen(unsigned int baudrate);
void PlpClose();
int PlpRead(unsigned char *portname, unsigned char *addr, unsigned char *buf, int *readlen);
int PlpRead(unsigned char *portname, unsigned char *addr, unsigned char *buf, int readlen);
int PlpReadAppoint(unsigned char *portname, unsigned char addr, unsigned char *buf, int n);
int PlpWrite(unsigned char *portname, unsigned char addr, unsigned char *buf, int n);

//函数调用

void __fastcall TForm1::Timer1Timer(TObject *Sender)
{
int ret1, ret2, readlen;
unsigned char addr, portname[10];
unsigned char rbuf[260];

Timer1->Enabled = false;
Timer1->Interval = 50;

readnext:
ret1 = PlpRead(portname, &addr, rbuf, &readlen);
if( readlen == 0 || ret1 < 0 )
{
Timer1->Enabled = true;
return;
}
do{
ret2 = PlpWrite(portname,addr,rbuf,readlen);
}while( ret2 < readlen);

if( ret1 > 0 ) goto readnext;
Timer1->Enabled = true;
}
//---------------------------------------------------------------------------
...全文
47 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
zjqyb 2003-08-23
  • 打赏
  • 举报
回复
Function PlpOpen(baudrate:DWORD):integer;
Procedure PlpClose();
Function PlpRead(portname,addr, buf:pchar;readlen:PINT):integer;
Function PlpRead(portname,addr, buf:pchar;readlen:integer):integer;overload;
Function PlpReadAppoint(portname, addr, buf:pchar;n:integer):integer;
Function PlpWrite(portname, addr, buf:pchar;n:integer):integer;

procedure TForm1.Timer1Timer(Sender:TObject );
var
ret1, ret2, readlen:integer;
addr:char;
portname:array[0..9] of char;
rbuf:array[0..259] of char;
begin
Timer1.Enabled := false;
Timer1.Interval := 50;
repeat
ret1: =PlpRead(portname, @addr, rbuf, @readlen);
Timer1.Enabled:=( readlen = 0) or (ret1 < 0 );
if not Timer1.Enabled then
exit;
repeat
ret2 := PlpWrite(portname,addr,rbuf,readlen);
until ret2 >= readlen;
until ret1 <= 0 ;
Timer1.Enabled := true;
end;
lxpbuaa 2003-08-22
  • 打赏
  • 举报
回复
Delphi区我已经给你回答了,别到处乱发了。

—————————————————————————————————
宠辱不惊,看庭前花开花落,去留无意;毁誉由人,望天上云卷云舒,聚散任风。
—————————————————————————————————
Introduction My desire to write a book about C++Builder has some history. I have beenvery impressed with Borland since their first edition of C++ (and prior editionsof C), because they have always made an effort to ensure quality. Unfortunately, there are very few books on the market about Borland C++or C++Builder, compared to other products like Visual Basic or VisualC++. Since different authors have different viewpoints of a product, I always prefer to consult more than one book to gain in-depth knowledge, as every author provides a unique service with his or her expertise. Also,authors are limited by their own onstraints; every book does not cover every aspect of the product. When I first used MIDAS a few years ago,there was not a book available to help me do my project. I spent a lot of time investigating answers for my questions in an iterative manner. I can say that my frustration over that prompted me to write this book on C++Builder. As with every release, C++Builder 6 is very rich with features. Best of all, you can build distributed objects in different technologies in the real RAD (rapid application development) way. To my knowledge, this is the only C++ implementation that enables you to build C++ applications on the fly, just as easy as with Delphi or Visual Basic. For programmers who are apprehensive of C++, I would recommend learning C++ using this product. I paid exclusive attention to three main subject areas of C++Builder 6:Windows application development, database development, and distributed systems development. Throughout the duration of this project, I attempted to make the book useful for every type of reader—a novice in C++Builder, a programmer experienced with the product, and those who already have books on prior editions of C++Builder. The entire book contains 12 chapters.Some chapters are relatively larger than we normally see in manybooks. To keep the flow of my thoughts continuous (which is very helpful for the reader), I did not want to break the chapters into smaller pieces. I divided the 12 chapters into two parts. The first part presents topics onWindows application development as well as database development. The second part is dedicated to distributed systems development and a few miscellaneous topics. Thus, I present more than 200+ pages on several distributed architectures, including DataSnap,WebBroker,WebSnap,BizSnap, CORBA, and TCP/IP. I also created a number of example projects,which you may directly compile on your computer, either for learning or for use in your own projects. Most of the source code for the examples is presented in the book and provided on the companion CD. However, you may need to have the Enterprise edition of C++Builder 6 to work on most of the second part of the book, since it covers advanced topics. For a couple of reasons, I did not present COM/ActiveX-related chapters in this book. The main reason is that almost all the available books on C++Builder present topics on COM-related technologies very well. In addition,Microsoft itself is drifting its focus away from COM-related technologies since they released the .NET framework, which would force many organizations to reduce the intensity of their COM-based application development. Slowly, many organizations will migrate their COM-based solutions to .NET or other distributed architectures.

13,825

社区成员

发帖
与我相关
我的任务
社区描述
C++ Builder相关内容讨论区
社区管理员
  • 基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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