migrating from Delphi to BCB

disclaimer

The two languages can be quite similar and quite portable. Following is a list of constructs that are quite similar.

Constructor

Var MyButton:TButton; 
MyButton:=TButton.create(self); 
MyButton.Parent:=self; 
TButton *MyButton;
MyButton = new TButton(this);
MyButton -> Parent=this;

Destructor

MyButton.destroy; MyButton->TButton::~TButton();

conditional compilation

 {$define ABCD} 
  ...
 {$ifdef ABCD}
  xxxxx 
 {$else}
  yyyyy 
 {$endif} 
 
 #define ABCD 
 ...
 #ifdef ABCD 
  xxxxx
 #else 
  yyyyy 
 #endif 
 

functions

 function abcd(u:integer):integer; 
 begin
  result:=0;
  inc(k);
 end; 
 
 // do it this way : have an internal 
 // variable named result or whatever
 
 int abcd(int u) 
 { 
  int myresult; 
  myresult =0; 
  k++;
  return myresult; 
 } 

 // don't do it this way : as return 
 // leaves the procedure immediately. 

 int abcd(int u) 
 { 
   return 0;     // leaves immediately. 
   k++;          // is never done !!! 
 }
 

deviations from the assumed

Some Delphi components work slightly different, this is due
to default array properties do not exist in BCB. Therefore the
variable holding the items has to be named.
 MyListBox.Items.Add(MyEdit.Text);
becomes
 MyListBox->Items->Strings->Add(MyEdit->Text);

advanced stuff : events and procedure templates

 type TMyEvent=procedure(u:integer); of object;
becomes
 typedef void __fastcall (__closure *TMyEvent)(int);

 type MyProcType=procedure(u:integer);
becomes
 typedef void (*MyProcType) (int);





my BCB
home

last updated: 26.dec.01

Copyright (99,2001) Ing.Büro R.Tschaggelar