Solved

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

Posted on 2000-04-13
2
347 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

Does Powershell have you tied up in knots?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

773 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