Page 1 of 1
How to reference an Object from one prg to another
Posted: Mon Feb 21, 2011 10:45 am
by CCH4CLIPPER
Hi
In Main.prg
========
1) DEFINE WINDOW MainForm ;
AT 0,0 ;
WIDTH 450 ;
HEIGHT 150 ;
MAIN;
@ (MainForm.height/2)-18,(MainForm.width/2)-200
PROGRESSBAR Progress_1 RANGE 0,100 WIDTH 400 HEIGHT 30
@ (MainForm.height/2)-48-18,(MainForm.width/2)-200
LABEL Label_001 VALUE "Completed :" WIDTH 400 HEIGHT18
END WINDOW
CENTER WINDOW MainForm
ACTIVATE WINDOW MainForm
2) In Another.prg
=============
nComplete := INT((nCounter/nTotalRec) * 100)
cComplete := LTRIM(STR(nComplete))
MainForm.Progress_1.Value := nComplete
MainForm.Label_001.Value := "Processing "+ str(nCounter)+'/'+ltrim(str(nTOtalRec))+CHR(13)+ "Percentage completed "+cComplete + "%"
Q. How do I reference MainForm.Progress_1.Value in Another.prg to the one created in Main.prg ?
CCH
http://cch4clipper.blogspot.com
Re: How to reference an Object from one prg to another
Posted: Mon Feb 21, 2011 11:30 am
by PeteWG
CCH4CLIPPER wrote:Hi
In Main.prg
========
1) DEFINE WINDOW MainForm ;
AT 0,0 ;
WIDTH 450 ;
HEIGHT 150 ;
MAIN;
@ (MainForm.height/2)-18,(MainForm.width/2)-200
PROGRESSBAR Progress_1 RANGE 0,100 WIDTH 400 HEIGHT 30
@ (MainForm.height/2)-48-18,(MainForm.width/2)-200
LABEL Label_001 VALUE "Completed :" WIDTH 400 HEIGHT18
END WINDOW
CENTER WINDOW MainForm
ACTIVATE WINDOW MainForm
2) In Another.prg
=============
nComplete := INT((nCounter/nTotalRec) * 100)
cComplete := LTRIM(STR(nComplete))
MainForm.Progress_1.Value := nComplete
MainForm.Label_001.Value := "Processing "+ str(nCounter)+'/'+ltrim(str(nTOtalRec))+CHR(13)+ "Percentage completed "+cComplete + "%"
Q. How do I reference MainForm.Progress_1.Value in Another.prg to the one created in Main.prg ?
CCH
http://cch4clipper.blogspot.com
Perhaps you could try to put on top of your Another.prg the line
DECLARE WINDOW MainForm
and see if it helps..
---
Pete
Re: How to reference an Object from one prg to another
Posted: Mon Feb 21, 2011 11:57 am
by CCH4CLIPPER
Hi Pete
TQVM for your speedy response
Just added DECLARE WINDOW MainForm to the top of my pay_mth.prg and still have syntax error
Compiling 'PAY_MTH.PRG'...
PAY_MTH.PRG(692) Error E0030 Syntax error "syntax error at '.'"
PAY_MTH.PRG(693) Error E0030 Syntax error "syntax error at '.'"
2 errors
Line 692 MainForm.Progress_1.Value := nComplete
Line 692 MainForm.Label_001.Value := "Processing "+ str(nCounter)+'/'+ltrim(str(nTOtalRec))+CHR(13)+ "Percentage completed "+cComplete + "%"
Any other suggestions ?
Re: How to reference an Object from one prg to another
Posted: Mon Feb 21, 2011 12:42 pm
by PeteWG
CCH4CLIPPER wrote:Hi Pete
TQVM for your speedy response
Just added DECLARE WINDOW MainForm to the top of my pay_mth.prg and still have syntax error
Compiling 'PAY_MTH.PRG'...
PAY_MTH.PRG(692) Error E0030 Syntax error "syntax error at '.'"
PAY_MTH.PRG(693) Error E0030 Syntax error "syntax error at '.'"
2 errors
Line 692 MainForm.Progress_1.Value := nComplete
Line 692 MainForm.Label_001.Value := "Processing "+ str(nCounter)+'/'+ltrim(str(nTOtalRec))+CHR(13)+ "Percentage completed "+cComplete + "%"
Any other suggestions ?
CCH4CLIPPER wrote:Hi Pete
TQVM for your speedy response
Just added DECLARE WINDOW MainForm to the top of my pay_mth.prg and still have syntax error
Compiling 'PAY_MTH.PRG'...
PAY_MTH.PRG(692) Error E0030 Syntax error "syntax error at '.'"
PAY_MTH.PRG(693) Error E0030 Syntax error "syntax error at '.'"
2 errors
Line 692 MainForm.Progress_1.Value := nComplete
Line 692 MainForm.Label_001.Value := "Processing "+ str(nCounter)+'/'+ltrim(str(nTOtalRec))+CHR(13)+ "Percentage completed "+cComplete + "%"
Any other suggestions ?
It is possible that the culprit is lying in another line of your code.
(for example: the line
@ (MainForm.height/2)-48-18,(MainForm.width/2)-200 LABEL Label_001 VALUE "Completed :" WIDTH 400 HEIGHT18
has a typo at HEIGHT18 (there is a missing space between 'HEIGHT' and '18')
By the way, could you post your starting lines of your PAY_MTH.PRG ?
---
Pete
Re: How to reference an Object from one prg to another
Posted: Mon Feb 21, 2011 1:32 pm
by CCH4CLIPPER
Hi Pete
1) Pay_mth.prg
DECLARE WINDOW MainForm
2) Just checked my codes, there is a space
BTW, just chatted with Sudip and he suggested using SETPROPERTY().
// MainForm.Progress_1.Value := nComplete
SETPROPERTY(MainForm,Progress_1,Value,nComplete)
//MainForm.Label_001.Value := "Processing "+ str(nCounter)+'/'+ltrim(str(nTOtalRec))+CHR(13)+ "Percentage completed "+cComplete + "%"
SETPROPERTY(MainForm,Label_001,Value,"Processing "+ str(nRunNo)+'/'+ltrim(str(nTOtNo))+CHR(13)+ "Percentage completed "+cComplete + "%")
It seems to work as there are no more compile errors reported by hbmk2
Cheers
CCH
http://cch4clipper.blogspot.com
Re: How to reference an Object from one prg to another
Posted: Mon Feb 21, 2011 4:37 pm
by Rathinagiri
In HMG4, the management of controls are entirely different. Previously a BIG public array is used to store all the windows/controls attributes (like name, handle, width, height, row, col etc).
HMG4 should also have such an array at least to hold the window/control object names. Until such time, you have to define the names of the controls/windows as public variables. Thereby you can refer an object from one prg to another.
Re: How to reference an Object from one prg to another
Posted: Tue Feb 22, 2011 10:39 am
by CCH4CLIPPER
Hi Rathinagiri
Thanks for your tip
CCH
http://cch4clipper.blogspot.com
Re: How to reference an Object from one prg to another
Posted: Thu Feb 24, 2011 1:42 am
by CCH4CLIPPER
Hi Rathinagiri
rathinagiri wrote:In HMG4, the management of controls are entirely different. Previously a BIG public array is used to store all the windows/controls attributes (like name, handle, width, height, row, col etc).
HMG4 should also have such an array at least to hold the window/control object names. Until such time, you have to define the names of the controls/windows as public variables. Thereby you can refer an object from one prg to another.
I tried declaring PUBLIC MainForm in the main.prg but referencing say in another.prg
MainForm.Progress_1.Value := nComplete
resulted in a Error E0030 Syntax error "syntax error at '.'"
This was despite DECLARE WINDOW MainForm (at top of another.prg) and explicitly declared MEMVAR Mainform
Please revert, TIA
CCH
http://cch4clipper.blogspot.com
Re: How to reference an Object from one prg to another
Posted: Thu Feb 24, 2011 4:00 am
by Rathinagiri
Thanks for reporting. I will check that out.