🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.delphi.language.objectpascal
Article #161

problem with Dynamic Array

#161
From: devotionguy
Date: Mon, 01 Jan 2007 12:43
75 lines
3512 bytes
hi friends
 here i am sending a problem that......there is a List of Instrument as
array.
and every instrument has symbol and other properties.the combination of
all properties is a Instrument.and many instrument can have same
symbol.now according to that Every symbol i have to make a list of
Instruments.and for a same symbol we have to make an array of
Instrument with length of 10 at a time for making a group of 3
consecutive instrument..............
like

Suppose a Symbol...TCS ..and total 45 Instruments  that means 45
Instrument have Symbol TCS
and i have to make a array of all the 45 Instruments....10+10+10+10+5
..in this way the setLength work....and in this set of 10
Instruments...all the 10 will make a group of 3 Instrument.......that
is1
1,2,3..2,3,4..3,4,5..4,5,6..5,6,7..7,8,9..8,9,10...
I am sending my code...plz help me to solve this problem
-----------------------------------------------------------------------------------------------------------------------------------------------
procedure TButterflyView.FormCreate(Sender: TObject);
var
  Query,Symbol: string;
  Token: array of Integer;
  I,J: Integer;
  Instrument: array of TInstrument;
  List: array of array of TInstrument;
begin
  inherited;
  MasterData := TFOMaster.Create();

  Query := 'select TOKEN from %s where INAME like ''OPT%%'' order by
SYMBOL,STPRICE,OTYPE';
  with MasterData.ExecQuery(Query) do
  begin
    try
      First;
      I := 0;
      SetLength(Token,RecordCount);
      while not Eof do
      begin
        Token[I] := Fields[0].AsInteger;
        Inc(I);Next;
      end;
    finally
      free;
    end;
  end;
  try
    SetLength(Instrument,Length(Token));
    I := 0;
    while I<=Length(Token) do
    begin
      Instrument[I] :=
MainForm.NSEFuturesMarket.FindInstrument(Token[I]);
      Inc(I);Next;
    end;
  finally
    free;
  end;
  I := 0;Symbol := '';
//  Symbol := (Instrument[I] as TFOContract).Symbol;
  if I<=Length(Instrument)-1 then
  begin
    if Symbol=(Instrument[I] as TFOContract).Symbol then
    begin
      if (I>-1) and (J>0) then SetLength(List[I],J);
      if I>=Length(List) then SetLength(List,I+10);
      Inc(I);J := 0;
      if J>=Length(List) then SetLength(List[I],J+10);
      List[I][J] := Instrument[I];
      Inc(J);
    end else Exit;
  end;
end;
Technical Details
Message-ID: <1167655437.709063.215960@42g2000cwt.googlegroups.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!postnews.google.com!42g2000cwt.googlegroups.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 109d30,d6d60b53bc94e02e,start
X-Google-Attributes: gid109d30,public
X-Google-Language: ENGLISH,ASCII-7-bit
Path: arc1-ca.pugleaf.net!g2news2.google.com!postnews.google.com!42g2000cwt.googlegroups.com!not-for-mail
From: "devotionguy@gmail.com" <devotionguy@gmail.com>
Newsgroups: borland.public.delphi.language.objectpascal
Subject: problem with Dynamic Array
Date: 1 Jan 2007 04:43:57 -0800
Organization: http://groups.google.com
Lines: 76
Message-ID: <1167655437.709063.215960@42g2000cwt.googlegroups.com>
NNTP-Posting-Host: 59.93.252.7
Mime-Version: 1.0
Content-Type: text/plain; charset="iso-8859-1"
X-Trace: posting.google.com 1167655443 14552 127.0.0.1 (1 Jan 2007 12:44:03 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Mon, 1 Jan 2007 12:44:03 +0000 (UTC)
User-Agent: G2/1.0
X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727),gzip(gfe),gzip(gfe)
X-HTTP-Via: 1.1 EISLBO
Complaints-To: groups-abuse@google.com
Injection-Info: 42g2000cwt.googlegroups.com; posting-host=59.93.252.7;
   posting-account=ttyYog0AAAAnKPo5pR-WgFquDnu0Nf_B