Solved

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

Posted on 2000-04-13
2
356 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 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 Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Strange behavior when a form is closed 6 69
URL for downloading Google Chrome for Win XP 2 236
FMX and jaudiotracker playing memory stream 29 98
Dynamically Created Query 3 70
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 Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

730 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