Object Question

I am programming in DBASE 2000.  It is a mixture of DBASE and Delphi.  Since they don't have a DBASE 2000 or DB2K topic I will submit my question here.

I have a form that has a notebook with tabs....   My program goes to a certain directory reads all .DBF files into an array then creates a notebook1 object using the file names as tab names.  After I get the size of the array or how many elements are in it.  I use the element count to figure out how many grid objects I will need.  I want to have a grid per-tab.  This is so the user can click on the notebook tab that he wants and view the .DBF file in the grid.

My problem is this.  I don't want to go and create a set number of grids.   I want to be able to create how many I need acording to how many elements are in the .DBF array.  I need to know if there is a way to do this.  This what I tried but DBASE 2000 gets confused.

For i = 1 to FileArray.Size
   MyGridName := "Grid" + i
   MyGridName = New Grid(form.notebook1)
Next i

I was hoping this would loop through this and names each grid.  I.E. Grid1, Grid2, Grid3, Grid4,..etc

Then I could go and run another loop and assign value to each grid properties.....
I.E.
  For i = 1 to FileArray.size
      With (Form.Notebook1.Grid + i)
         left := 1.00
         pageno := 2
      Endwith
  Next i




Please help.   I need to make this work.  
strongdAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

TicketToTotalitarianismCommented:
I've taken a standard 'Tabbed Notebook Dialog' from File->New->Other->Forms->Tabbed Pages. Delphi 6.

Then I've added TabSheets as a public member to the form.

The OK-button makes 5 new tabsheets.
The Cancel-button deletes all tabsheets.

Should work rightaway.

good luck,
Frank


unit Unit2;

interface

uses Windows, SysUtils, Classes, Graphics, Forms, Controls, StdCtrls,
  Buttons, ComCtrls, ExtCtrls;

type
  TPagesDlg = class(TForm)
    Panel1: TPanel;
    Panel2: TPanel;
    PageControl1: TPageControl;
    TabSheet3: TTabSheet;
    OKBtn: TButton;
    CancelBtn: TButton;
    HelpBtn: TButton;
    procedure OKBtnClick(Sender: TObject);
    procedure CancelBtnClick(Sender: TObject);
  private
    { Private declarations }
  public
    TabSheets : array of TTabsheet; // the new tabsheets
  end;

var
  PagesDlg: TPagesDlg;

implementation

{$R *.dfm}

procedure TPagesDlg.OKBtnClick(Sender: TObject);
var
  t : integer;
const
  newLength = 5;
begin
  // set length of Tabsheets-array
  SetLength(tabsheets,newlength);
  // create al Tabsheets
  for t := 0 to high(tabsheets) do
  begin
    tabsheets[t] := TTabSheet.Create(self);
    TabSheets[t].Parent := self;
    TabSheets[t].PageControl := PageControl1;
    TabSheets[t].Caption := 'Grid ' + inttostr(t);
    TabSheets[t].name := 'Grid ' + inttostr(t);
  end;
end;

procedure TPagesDlg.CancelBtnClick(Sender: TObject);
begin
  // delete all tabsheets
  for t := 0 to high(tabsheets) do
    1TabSheets[t].Destroy;

  // clear array
  setlength(tabsheets,0);
end;

end.
0
strongdAuthor Commented:
That is not what I am asking...  Basicly I am asking...   How do you make objects with variable names..???


0
TicketToTotalitarianismCommented:
You can't.

[quote]
My problem is this.  I don't want to go and create a set number of grids.
[/quote]
so no static array.
[quote]
I want to be able to create how many I need acording to how many elements are in the .DBF array.  
[/quote]
You want a dynamic array. (!)

if you for-loop through all the elements,
then you know how many elements you have,
and set the length of the dynamic array like this:
SetLength(tabsheets,[newlength]); (see previous example)

or while-loop through all the elements
and add with every iteration a new element:
while not (the end of dbase} do
begin
  // set array-length 1 higher
  SetLength(tabsheets,length(tabsheets)+1);
  // create new tabsheet
  tabsheets[length(tabsheets)-1] := TTabSheet.Create(self);
  // go to next element in DBase
  next;
end

[quote]
I need to know if there is a way to do this.
[/quote]
There is , but don't use variable names, but variable arrays :D

Use TabSheets[t].name := 'Grid ' + inttostr(t);
to set the name of a tabsheet.

For/while-loop through the array to find the sheet you want.
while assigned(TabSheets[t]) and (not TabSheets[t].name = 'Grid 2') do t := t+1;
result := Tabsheet[t];
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

CleanupPingCommented:
strongd:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
strongdAuthor Commented:
None of the people answered the question.  How do I get my points back?

0
strongdAuthor Commented:
The problem was never solved.   What these people told me to do, didn't work.  First off, I was working with DBase2000.  Experts Exchange doesn't even have a DBASE2000 or DBASE section.  So I never got it working and took a different route.  

I took another job about 2 months after I submitted this question.  I can't remember what I accually did to get around this.

Hopefully I can get my some of my points refunded.




0
strongdAuthor Commented:
What TicketToTotalitarianism suggested never worked!  Why are you guys forcing me to give him the points????

What he suggested to try never worked!

I guess I will have to be careful of how many points I post... because you guys will force me to accept answer even if it is wrong...

0
strongdAuthor Commented:
Sorry... I am no longer working in the that area.  Even if I was, because I was working on classified data for the Air Force, I couldn't post the code anyway.  Anything I wrote on a classified system, it is classified.  The code becomes classified, and the Air Force owns it.   If I posted code that was "CLASSIFED" I could go to jail.  





0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.