Solved

i want to change the c++ code to delphi code!

Posted on 2000-04-13
2
334 Views
Last Modified: 2008-03-04
I write a bc++ code :
void __fastcall TForm1::FormCreate(TObject *Sender)
{





 while(!Query1->Eof)
  {
      char szName[255];
      // get data from first table
      // and save data into csc
      String csc = Query1->FindField("STKCODE")->AsString;
      String mkt = Query1->FindField("MKT")->AsString;
      // into csc to second table and get data

      if(mkt == "TSE"){
      Query2->Close();

      Query2->SQL->Clear();
      Query2->SQL->Add("select stkcode,syear*100+smon,sb_vol,lb_vol/100,cp");
      Query2->SQL->Add("from ap.amgin");
      Query2->SQL->Add("where STKCODE =:sss");
      Query2->SQL->Add("and syear*100+smon >199702");
      Query2->ParamByName("sss")->AsString= csc;
      Query2->Active=TRUE;

     // use the data of second table to draw the line chart
      Series1->DataSource=Query2;
      Series1->ParentChart=DBChart1;
      Series1->XLabelsSource="syear*100+smon";
      Series1->YValues->ValueSource= "lb_vol/100";
      Series2->DataSource=Query2;
      Series2->ParentChart=DBChart1;
      Series2->XLabelsSource="syear*100+smon";
      Series2->YValues->ValueSource= "sb_vol";
      Series3->DataSource=Query2;
      Series3->ParentChart=DBChart1;
      Series3->XLabelsSource="syear*100+smon";
      Series3->YValues->ValueSource= "cp";
      wsprintf(szName,"c:\\gmgin\\gmgintse%s.bmp",csc);
      DBChart1->SaveToBitmapFile(szName);
      Query1->Next();
      }
      else{
       Query2->Close();

      Query2->SQL->Clear();
      Query2->SQL->Add("select stkcode,syear*100+smon,sb_vol,lb_vol/100,cp");
      Query2->SQL->Add("from ap.amgin");
      Query2->SQL->Add("where STKCODE =:sss");
      Query2->SQL->Add("and syear*100+smon >199702");
      Query2->ParamByName("sss")->AsString= csc;
      Query2->Active=TRUE;

     // use the data of second table to draw the line chart
      Series1->DataSource=Query2;
      Series1->ParentChart=DBChart1;
      Series1->XLabelsSource="syear*100+smon";
      Series1->YValues->ValueSource= "lb_vol/100";
      Series2->DataSource=Query2;
      Series2->ParentChart=DBChart1;
      Series2->XLabelsSource="syear*100+smon";
      Series2->YValues->ValueSource= "sb_vol";
      Series3->DataSource=Query2;
      Series3->ParentChart=DBChart1;
      Series3->XLabelsSource="syear*100+smon";
      Series3->YValues->ValueSource= "cp";
      wsprintf(szName,"c:\\gmgin\\gmginotc%s.bmp",csc);
      DBChart1->SaveToBitmapFile(szName);
      Query1->Next();
      }

 }

}


now i want to change to the delphi code
but Have a lot of error .
how will i change!
the delphi code :
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  Grids, DBGrids, Db, DBTables, ExtCtrls, TeeProcs, TeEngine, Chart,
  DBChart, StdCtrls, Series;

type
  TForm1 = class(TForm)
    DBChart1: TDBChart;
    Query1: TQuery;
    DataSource1: TDataSource;
    DBGrid1: TDBGrid;
    Edit1: TEdit;
    Query2: TQuery;
    DataSource2: TDataSource;
    DBGrid2: TDBGrid;
    Series1: TLineSeries;
    Series2: TLineSeries;
    Query3: TQuery;
    DataSource3: TDataSource;
    Query4: TQuery;
    DataSource4: TDataSource;
    DBGrid3: TDBGrid;
    DBGrid4: TDBGrid;
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.DFM}


procedure TForm1.FormCreate(Sender: TObject);
// var szName:array[0..255] of char;
var ind_tek,mkt:string;
begin

     while Query1.Eof <> true  do
     begin
          ind_tek := Query1.FindField('STKCODE').AsString;
          mkt :=Query1.FindField('MKT').AsString;
          Edit1.Text := mkt;
          if mkt=('TSE')
          then

                 Query2.Close();
                 Query2.SQL.Clear();
                 Query2.SQL.Add('select syear*100+smon,cp');
                 Query2.SQL.Add('from ap.aprcm');
                 Query2.SQL.Add('where stkcode = :mem');
                 Query2.SQL.Add('and (syear*100+smon)>199702');
                 Query2.ParamByName('mem').AsString := ind_tek;
                 Query2.Active :=TRUE;


           Series1.DataSource:=Query2;
           Series1.ParentChart:=DBChart1;
           Series1.XLabelsSource:='syear*100+smon';
           Series1.YValues.ValueSource := 'cp';
           Series2.DataSource:=Query3;
           Series2.ParentChart:=DBChart1;
           Series2.XLabelsSource:='syear*100+smon';
           Series2.YValues.ValueSource := 'cp';

           // wsprintf(szName,'e:\\gprcm\\gprcm%s.bmp',ind_stk);
           DBChart1.SaveToBitmapFile('e:\\gprcm\\gprcm'+'ind_stk'+'.bmp');
           Query1.Next();
           END

         else
           begin
      Query2.Close();
      Query2.SQL.Clear();
      Query2.SQL.Add("select syear*100+smon,cp");
      Query2.SQL.Add("from ap.aprcm");
      Query2.SQL.Add("where stkcode=:mem");
      Query2.SQL.Add("and syear*100+smon>199702");
      Query2.ParamByName("mem").AsString:=ind_stk;
      // Query2->Prepare();
      Query2->Active = TRUE;

      Series1.DataSource:=Query2;
      Series1.ParentChart:=DBChart1;
      Series1.XLabelsSource:='syear*100+smon';
      Series1.YValues.ValueSource := 'cp';
      Series2.DataSource:=Query4;
      Series2.ParentChart:=DBChart1;
      Series2.XLabelsSource:='syear*100+smon';
      Series2.YValues.ValueSource := "cp";

      // wsprintf(szName,'e:\\gprcm\\gprcmotc%s.bmp',ind_stk);
      // DBChart1.SaveToBitmapFile(szName);
      Query1.Next();
      end


end;

end.
thanks for your help
             eric
0
Comment
Question by:erichuang
2 Comments
 
LVL 12

Accepted Solution

by:
rwilson032697 earned 200 total points
ID: 2714442
You need to chagne the following:

Change the -> to .
Change " to '
Change \\ to \
Remove () from end of functions (actually I think Delphi will compile this, but they should be removed...)

You should convert { to BEGIN and } to END from your C++ code - you seem just to have deleted the {}'s

Cheers,

Raymond.

0
 

Author Comment

by:erichuang
ID: 2721938
thanks for your help.
i will try your suggest after few day.
thanks,
             eric
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now