Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change array data in one of two forms from form 3

Status
Not open for further replies.

Opieo

Programmer
Jul 26, 2006
454
GB
Hey guys, I need a little bit of help here.

I have two sets of programs where some of the data they use on parts overlaps. However, each set of programs differs slightly for what they need, and greatly on all levels below this top level.
For that reason I made a form for each set of programs. (Programs here is referring to program names for customers, not a bunch of software programs) Now there is one form that they call that edits this top level data. Since the top level data is mostly the same, I figured for just this level I would use the same form to edit the data. The part of my function that alters the database works just fine with a single If Then. However, the part where I am stuck is where I need this data changing form to change the data held in an array on one of the two forms that called this guy. I do not seem to be having much luck in not getting an error trying to assign something to point at one or the other's array. I want to do this so that editing the data will still work the same as before with just a single If Then.

It is possible that this data changing form needs to increase the size of the array on the form that called it. Before when we had one main customer this was quite simple. Now that I need just a variable that points to one or the other I seem to be blocked. I know this should be quite simple and I feel I am just not looking in the right direction.
Any suggestions for me to study up on here?

~
“Your request is not unlike your lower intestine: stinky, and loaded with danger.” — Ace Ventura.
 
I'd need to see some of the code. Show us where you're declaring the array type, the variables used to point to the array, and the method you're using to do what you're trying to do to the array.

Please don't copy and paste your whole project, just show us the bits that are relevant to your question.
 
Here is pretty much my ideal situation I would like but it tells me incompatible types (which is understandable).

There is a record called TVersion on TForm1 and TForm2
Code:
type     // For the VERSIONS table
  TVersion = record
    Version : String[50];
    Progrm  : String[15];
    Manager : String[30];
   etc, etc
This is common except for a few fields towards the bottom.
Either of these can call TForm3 and in TForm3 I am trying to do this:

Code:
 var
  MyArray : array of TVersion;
 begin
  ...
    if (MDIParent.CurrComp = 'GM') then
     MyArray := MDIParent.ChildMenu.DBVers
    else
     MyArray := MDIParent.ChildBMWMenu.DBParts;
    SetLength (MyArray, k + 1); 
    MyArray[k].Version := versi.Text;
    MyArray[k].Progrm  := progr.Text;

Because the specifics of TVersion differ, it is giving me the incompatible type error.
This was my first idea. I have also tried using pointers, but with less success than this as I got more errors then.

~
“Your request is not unlike your lower intestine: stinky, and loaded with danger.” — Ace Ventura.
 
Actually, after some reading and being pointed in a direction by a friend I will be switching over the arrays to act much more object oriented. I just need to brush up on that to make sure I'm up to pace on creating the interface and all. Fun fun.
Best times to learn are when you need to do something you don't know how to do. I almost love these situations =)

~
“Your request is not unlike your lower intestine: stinky, and loaded with danger.” — Ace Ventura.
 
As you seem to be aware, you cannot assign one type to another in this way. You could declare MyArray as the same type as what DBVers is - that would allow you to assign the arrays using the code above.

If you end up changing TVersion into a class object, I recommend using a TObjectList as the container for them, rather than a dynamic array.

If you need further help, please post the type declarations of MDIParent.ChildMenu.DBVers and MDIParent.ChildBMWMenu.DBParts.

I suspect they may be different, in which case you're going to have further issues in assigning them to the same type object.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top