Error in SetProperty()

Moderator: Rathinagiri

Post Reply
Ricci
Posts: 255
Joined: Thu Nov 19, 2009 2:23 pm

Error in SetProperty()

Post by Ricci » Mon Oct 10, 2011 2:51 pm

SetProperty() isn´t working anymore.

That should be the same:

Code: Select all

Form_7:LabelY01:Value("")

SetProperty ( "Form_7", "LabelY01", "Value", "" )
But SetProperty() returns an error: Variable does not exist: Form_7
And after that error, the program must be closed via task manager.

Some days ago it workes quit well.

mrduck
Posts: 497
Joined: Fri Sep 10, 2010 5:22 pm

Post by mrduck » Mon Oct 10, 2011 3:04 pm

First of all PLEASE don't use Set/GetProperty anymore, it is a HMG3-thing that is only partially ported to HMG4 and introduces some slowness - use only when strictly necessary... :-)
Ricci wrote:Some days ago it workes quit well.
I introduced some changes on september 19, so you should be more precise on "some days ago"... :-)

Anyway, you are sayint that using

Code: Select all

Form_7:LabelY01:Value("")
works correctly but if you put the following line AT THE SAME PLACE it doesn't work, right ?

Code: Select all

SetProperty ( "Form_7", "LabelY01", "Value", "" )
If you confirm, please have a look at misc.prg:

Code: Select all

FUNCTION SetProperty( cWindow , cControl , cProperty , xValue1, xValue2 )

   IF pcount() == 4
      &cWindow:&cControl:&cProperty := xValue1
      RETURN xValue1
The error that variable Form_7 doesn't exists let me think that Form_7 is LOCAL... visible to the OOP syntax, not visible to SetProperty....

Please try this:

Code: Select all

FUNCTION SetProperty( cWindow , cControl , cProperty , xValue1, xValue2 )

   IF pcount() == 4
      HMGAPP():&cWindow:&cControl:&cProperty := xValue1  // HERE IS THE CHANGE
      RETURN xValue1
and report.

With the change the window is not referenced by its variable but by its name. Not sure if there is a side-effect so I can't commit it now....

Ricci
Posts: 255
Joined: Thu Nov 19, 2009 2:23 pm

Post by Ricci » Mon Oct 10, 2011 3:52 pm

mrduck wrote: The error that variable Form_7 doesn't exists let me think that Form_7 is LOCAL... visible to the OOP syntax, not visible to SetProperty....

Please try this:

Code: Select all

FUNCTION SetProperty( cWindow , cControl , cProperty , xValue1, xValue2 )

   IF pcount() == 4
      HMGAPP():&cWindow:&cControl:&cProperty := xValue1  // HERE IS THE CHANGE
      RETURN xValue1
and report.
With this change it work well.
And yes, Form_7 was definded as LOCAL.

Post Reply