View Full Version : How to reference buttons or other objects, in other pages?
hliobasilema
03-31-2009, 06:00 AM
Consider the following code (lets say inside an 'On Show' event)
--this will return the text displayed on Button1 on the current page
Button.GetText ("Button1");
How can i do this?
Specific_Page.Button.GetText("Button1");
I hope somebody can help:rolleyes
hliobasilema
03-31-2009, 06:20 AM
Similarly,
object_names = Page.EnumerateObjects(); --this will get the names of all of the objects on the current page.
-- How can i do the same but for a specific page?
i.e. Specific_Page.EnumerateObjects();
longedge
03-31-2009, 06:27 AM
The page doesn't exist and can't be referenced until it is displayed (a.f.a.i.k.)
If it's essential to do this, then one method would be to dynamically populate objects on a page from say a text/ini file. This could be referenced at any time, via the text/ini file.
Dependant on the number of pages in your project, it may be possible to use a single page and simply hide/show objects when required which obviously would mean that they could then be referenced directly. Although I don't produce large projects, the ones that I do are now almost always a single page using this method whereas I used to produce 10 or 20 pages doing what I now do on 1 page. Dynamic loading of text and hiding/showing objects works really well once you get into it.
hliobasilema
03-31-2009, 06:43 AM
The page doesn't exist and can't be referenced until it is displayed (a.f.a.i.k.)
In this example we can reference all the pages in our project (well only the names, not the pages themselves)
--Get the names of all pages in the app
all_pages=Application.GetPages();
So if we can reference all the names of our pages in the project, there must be a way of referencing the pages themselves,
probably my means of overriding some of the built-in functions say?
If it's essential to do this, then one method would be to dynamically populate objects on a page from say a text/ini file. This could be referenced at any time, via the text/ini file.
Could you give an example code of this to get me started?
the ones that I do are now almost always a single page using this method whereas I used to produce 10 or 20 pages doing what I now do on 1 page. Dynamic loading of text and hiding/showing objects works really well once you get into it.
In some of my pages i use the idea of dynamically hiding/showing objects.
But doesn't this clutter up your design view a lot???
longedge
03-31-2009, 06:56 AM
In some of my pages i use the idea of dynamically hiding/showing objects.
But doesn't this clutter up your design view a lot???
Speaking personally I don't have a problem and I understand that for some people when designing a very 'busy' page it wouldn't be practical. I tend to have a paragraph, video a couple of labels and two or three buttons visible and I stack alternative objects.
I keep the project explorer pane open and for what I do it works fine.
If I have a moment, I'll look at making a small example.
hliobasilema
03-31-2009, 07:06 AM
Longedge i want to thank you for you quick and informative replies!
I really appreciate all people like you who have the spirit of helping out their fellows.
Thanks to all of you guys and to indigorose for providing us this forum
hliobasilema
03-31-2009, 07:32 AM
The underlying need for requiring me to reference other pages from within other pages, is that i have built a project so far containing about 50 pages.
Then i decided to create a keyword index using the Application.MakeKeywordIndex built-in functionality. But to my surprise i had forgotten to manually enter info in the keyword field of the pages.
So ultimately i am trying to automate the process of initialising all keyword fields
at runtime. I want the keywords for each page to be the text displayed on the buttons of that page.
I provide you with some pseudocode:
loop_though_all_pages_of_the_project();
for each page
do
-find all button objects and retrieve their text value
-store the result to a variable
-initialise the keyword field of the page with our variable above
p.s. IF you feel this should be the subject of a new thread, please advise me
longedge
03-31-2009, 07:44 AM
Longedge i want to thank you for you quick and informative replies!
I really appreciate all people like you who have the spirit of helping out their fellows.
Thanks to all of you guys and to indigorose for providing us this forum
:) You're very welcome. The inmportant thing about the forum is that there are people of every level of ability in here. I'm not a programmer, just been using AMS a long time but we have the safety net of other members who are more capable than me.
That said, here's a small example of dynamic population of text in the objects on a page.
longedge
03-31-2009, 07:49 AM
After your further explanation, I would look at creating a global function to do this, although this is still dependant on the user visiting each page first. I can't think of an easy way off the top of my head.
You cerainly don't want to be trying to implement something like I suggested at this stage :)
hliobasilema
03-31-2009, 08:09 AM
Thanks once again!
I see what you mean about dynamic population of text. The problem is that in my case i would
still have to manually create that text file(containing the displayed button names) for each page.
The only way of automating it would be to visit the page, as you said in your last post.
All suggestions are welcome, and bravo to you for not being a programmer and still knowing quite a lot.
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.