Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > General

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 04-30-2012, 11:56 AM
Harry Harry is offline
Junior Member
 
Join Date: Apr 2012
Posts: 1
Default Arrays over 2 units

Hello

I am making a program that requires two forms and thus 2 units. My information only gets into the array once the first form activates and I need to get the information into unit 2 so I can use it on the second form. I have added both units to each others uses.

Here is my coding declarations:

//unit1


unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls, ExtCtrls, Menus,unit2,jpeg;

type
TfrmTrans = class(TForm)
redtrans1: TRichEdit;
BTNtrans: TButton;
redtrans2: TRichEdit;
edtsword: TEdit;
lbltrans1: TLabel;
rgptrs1: TRadioGroup;
rgptrs2: TRadioGroup;
imgbackground: TImage;
MainMenu1: TMainMenu;
ranslate1: TMenuItem;
WordgameBlink1: TMenuItem;
procedure BTNtransClick(Sender: TObject);
procedure FormActivate(Sender: TObject);
procedure WordgameBlink1Click(Sender: TObject);
procedure FormClose(Sender: TObject; var Action: TCloseAction);



private
{ Private declarations }
public
{ Public declarations }
end;

CONST MAXWORDS = 58112 ;

var
frmTrans: TfrmTrans;
arrEnglish : array[1..maxwords] of string ;
arrAfrikaans : array[1..MAXWORDS] of string ;

myEng, myAfk :TextFile ;
iEng,iAfk, I ,k: integer ;
sword ,sword2 :String;

icountwords : integer ;

implementation

//unit 2

unit Unit2;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls;

type
Tfrmwordgame = class(TForm)
btnwgstart: TButton;
LBLWG: TLabel;
EDTWG: TEdit;
btncheckans: TButton;
RichEdit1: TRichEdit;
procedure btnwgstartClick(Sender: TObject);
procedure FormActivate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;


var
frmwordgame: Tfrmwordgame;


iwg : integer ;
implementation

uses Unit1;

{$R *.dfm}

procedure Tfrmwordgame.btnwgstartClick(Sender: TObject);

begin

iwg := random(58000) + 1 ;
ShowMessage(IntToStr(iwg));
RichEdit1.Lines.Add(frmtrans.arrEnglish(iwg));
Reply With Quote
  #2  
Old 04-30-2012, 04:43 PM
Ouiji Ouiji is offline
Senior Member
 
Join Date: Nov 2001
Location: US of A
Posts: 478
Send a message via AIM to Ouiji
Default

You might want to try moving:
arrEnglish : array[1..maxwords] of string ;
into Public declarations on your main/first form, and removing it from the 2nd form.
Right now you are calling the array on form2 which has the same name, but is in no way linked to the array on your first form. Putting it in the public dec's should allow you to call it on your second from with the existing data.
__________________
"not quite smart enough to be dumb"
Extended Stats No Longer Available Due To Changes To The Forum.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT. The time now is 12:42 AM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2013, vBulletin Solutions, Inc.