Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to assign to a variable as reference or make an alias of a control

7 views
Skip to first unread message

Neil

unread,
Oct 22, 2009, 3:32:29 AM10/22/09
to
Hi everyone, I happen to have this structure that is
considerably long. example, I have a control structure like
this:

tab_1.page1.tab_2.page1.tab_3.page1.dw_1

Accessing dw_1 in code would make my code too long. I would
like that in code, I can maybe declare a datawindow variable
(ldw_ref) and assign dw_1 into that variable as reference so
that in code, I may just write it shorter. Instead of
writing, tab_1.page1... until I reached dw_1. repeating that
for all columns of dw_1 is so tedious to write.

All I know is that I can pass it to a function as reference.
But I am not coding in a function. Is there any other way to
achieve the above outside a function?

TIA
Neil

Jeremy Lakeman

unread,
Oct 22, 2009, 3:56:31 AM10/22/09
to

Yep, just like that.

datawindow ldw_1
ldw_1 = tab_1.page1.tab_2.page1.tab_3.page1.dw_1

ldw_1.retrieve()
...

Ivaylo Ivanov

unread,
Oct 22, 2009, 4:19:26 AM10/22/09
to
This technique can be further improved to become a general way of
referencing all the datawindow controls within the form:

1) declare instance array of datawindow type:
datawindow dws[]

2) for each of the datawindow controls within tabpages declare instance
constant to be used as index within the array:
constant integer CI_DW_MAIN = 1
constant integer CI_DW_EDU = 2
constant integer CI_DW_HIST = 3
etc...

3) on window opening prepare the array, just like Jeremy wrote:
dws[CI_DW_MAIN] = tab_1.page1.dw_main
dws[CI_DW_EDU] = tab_1.page1.tab_2.page1.dw_education
dws[CI_DW_HIST] = tab_1.page1.tab_2.page1.tab_3.page1.dw_1
etc.

4) after that, simply use dws[<CI_dw_constant>] to reference the desired
control

And I hope that the example you wrote
"tab_1.page1.tab_2.page1.tab_3.page1.dw_1" is not a real thing - I would
prefer to put meaningful suffixes of the controls instead of the default
numeric ones :-)

Regards,
Ivaylo

"Jeremy Lakeman" <jeremy....@gmail.com> wrote in message
news:530b500c-d10b-44de...@b25g2000prb.googlegroups.com...

Neil

unread,
Oct 22, 2009, 5:42:30 AM10/22/09
to
Thank you very much.

0 new messages