?
Solved

Object Question

Posted on 2003-03-25
12
Medium Priority
?
142 Views
Last Modified: 2010-04-04
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.  
0
Comment
Question by:strongd
[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
  • 5
  • 2
12 Comments
 

Expert Comment

by:TicketToTotalitarianism
ID: 8206852
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
 

Author Comment

by:strongd
ID: 8211218
That is not what I am asking...  Basicly I am asking...   How do you make objects with variable names..???


0
 

Accepted Solution

by:
TicketToTotalitarianism earned 500 total points
ID: 8211729
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Expert Comment

by:CleanupPing
ID: 9316613
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
 

Author Comment

by:strongd
ID: 10649270
None of the people answered the question.  How do I get my points back?

0
 

Author Comment

by:strongd
ID: 10667717
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
 

Author Comment

by:strongd
ID: 10688225
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
 

Author Comment

by:strongd
ID: 10688400
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

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
This is my first video review of Microsoft Bookings, I will be doing a part two with a bit more information, but wanted to get this out to you folks.
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

752 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