When must I use set/get property?

Topic Specific Tutorials and Tips.

Moderator: Rathinagiri

Post Reply
bluebird
Posts: 172
Joined: Wed Sep 28, 2016 3:55 am
DBs Used: DBF

When must I use set/get property?

Post by bluebird »

Learning Question

If I use a line of code like

Win_1.Button1.enabled:= .F. I may get an error that I can
solve with Setproperty("Win_1","Button1","enabled",.F.)

Please explain the rules for when you must use set/getproperty functions

Thanks
User avatar
mol
Posts: 3718
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Contact:

Re: When must I use set/get property?

Post by mol »

When your form Win_1 is known earlier or if you declare Win_1, you can use first statement. If you form Win_1 is loaded/declared/defined in other module (.prg) only SetProperty will work.
User avatar
serge_girard
Posts: 3161
Joined: Sun Nov 25, 2012 2:44 pm
DBs Used: 1 MySQL - MariaDB
2 DBF
Location: Belgium
Contact:

Re: When must I use set/get property?

Post by serge_girard »

This reminds me to the following important difference:

Code: Select all

some_form := 'FORM_1'
some_field := 'FIELD_1'

nVAR := GetProperty(some_form, some_field, 'Value')
// or
SetProperty(some_form, some_field, 'Value', nVAR)

/* is impossible with &some_form.&some_field.Value :=  x */
There's nothing you can do that can't be done...
Post Reply