How to reference an Object from one prg to another
Moderator: Rathinagiri
-
CCH4CLIPPER
- Posts: 140
- Joined: Tue Mar 03, 2009 8:59 am
How to reference an Object from one prg to another
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
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
Perhaps you could try to put on top of your Another.prg the lineCCH4CLIPPER 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
DECLARE WINDOW MainForm
and see if it helps..
---
Pete
-
CCH4CLIPPER
- Posts: 140
- Joined: Tue Mar 03, 2009 8:59 am
Re: How to reference an Object from one prg to another
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 ?
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
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.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 ?
(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
-
CCH4CLIPPER
- Posts: 140
- Joined: Tue Mar 03, 2009 8:59 am
Re: How to reference an Object from one prg to another
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
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
- Rathinagiri
- Posts: 5482
- Joined: Tue Jul 29, 2008 6:30 pm
- DBs Used: MariaDB, SQLite, SQLCipher and MySQL
- Location: Sivakasi, India
- Contact:
Re: How to reference an Object from one prg to another
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.
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.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
South or North HMG is worth.
...the possibilities are endless.
-
CCH4CLIPPER
- Posts: 140
- Joined: Tue Mar 03, 2009 8:59 am
-
CCH4CLIPPER
- Posts: 140
- Joined: Tue Mar 03, 2009 8:59 am
Re: How to reference an Object from one prg to another
Hi Rathinagiri
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
I tried declaring PUBLIC MainForm in the main.prg but referencing say in another.prgrathinagiri 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.
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
- Rathinagiri
- Posts: 5482
- Joined: Tue Jul 29, 2008 6:30 pm
- DBs Used: MariaDB, SQLite, SQLCipher and MySQL
- Location: Sivakasi, India
- Contact:
Re: How to reference an Object from one prg to another
Thanks for reporting. I will check that out.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
South or North HMG is worth.
...the possibilities are endless.