?
Solved

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

Posted on 2000-04-13
2
Medium Priority
?
370 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 12

Accepted Solution

by:
rwilson032697 earned 600 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses
Course of the Month12 days, 18 hours left to enroll

777 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