![]() |
|
#1
|
|||
|
|||
|
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)); |
|
#2
|
|||
|
|||
|
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.
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|