PDA

View Full Version : Combobox menu


Rikard
05-24-2005, 06:26 AM
Hi I am just playing around with autoplay and trying to learn how it works.
If anyone has the time to answer my question I would appreciate it and maybe I learn something.

I want to make a combobox dropdown menu.
I want it to take all my pages add them to the menu and page.jump to selected page

Sorry if im writing kind of short but my English is not the best.

Thanks
Rikard

yosik
05-24-2005, 07:57 AM
You can use the following actions:

-- read page names into table
all_pages = Application.GetPages();

-- count number of pages
ttl_pages = Table.Count(all_pages);

--Populate your Combo Box (starting from page 2 as page1 is where your combo box is located)
ComboBox.SetUpdate("yourCombo", false);
for i = 2, ttl_pages do
ComboBox.AddItem ("yourCombo", all_pages[i],"");
end
ComboBox.SetUpdate("yourCombo", true);

Good luck

Yossi

TJ_Tigger
05-24-2005, 08:26 AM
I have done this as well. If you don't want your page to be visible in the combobox you can add this

-- read page names into table
all_pages = Application.GetPages();

-- count number of pages
ttl_pages = Table.Count(all_pages);

--Populate your Combo Box (starting from page 2 as page1 is where your combo box is located)
ComboBox.SetUpdate("yourCombo", false);
for i = 1, ttl_pages do
if all_pages[i] ~= Application.GetCurrentPage() then
ComboBox.AddItem ("yourCombo", all_pages[i],"");
end
end
ComboBox.SetUpdate("yourCombo", true);

Rikard
05-24-2005, 08:48 AM
Thanks for the answer.
TJ_Tiger you are refering to the number in the combobox of the file thats not gona show.
Lets say im adding alot of files so that number wont be corect.
e.g. i have 2 files that i dont want to show "file1 and "file2" is it posible to putt in the names instead in the code or maby even better putt some code on the page that i dont want to show so it wont show up in the list

TJ_Tigger
05-24-2005, 09:02 AM
Thanks for the answer.
TJ_Tiger you are refering to the number in the combobox of the file thats not gona show.
Lets say im adding alot of files so that number wont be corect.
e.g. i have 2 files that i dont want to show "file1 and "file2" is it posible to putt in the names instead in the code or maby even better putt some code on the page that i dont want to show so it wont show up in the list


Certainly,

All you need to do is add some if this or that statements or use a table containing all the page names you don't want to display. Yoss's code is great for dynamically filling the ComboBox, that way if you add more pages they will be added to the list automatically. No additional coding required from you. If you have pages you don't want to be displayed you can do this:

-- read page names into table
all_pages = Application.GetPages();

-- count number of pages
ttl_pages = Table.Count(all_pages);

-- reset the comboBox content
ComboBox.ResetContent("yourCombo");

--Populate your Combo Box (starting from page 2 as page1 is where your combo box is located)
ComboBox.SetUpdate("yourCombo", false);
for i = 1, ttl_pages do
--list of pages not to show. As long as the name is not equal to one of
-- these pages will not be displayed.
if all_pages[i] ~= "EasterEgg" or all_pages[i] ~= "Secret" or all_pages[i] ~= "Admin" then
ComboBox.AddItem ("yourCombo", all_pages[i],"");
end
end
ComboBox.SetUpdate("yourCombo", true);

TJ_Tigger
05-24-2005, 09:06 AM
Another option I have used recently is to have a string containing a list of names not to be displayed and then using String.Find to search the string and if it is not found then add the list.

-- read page names into table
all_pages = Application.GetPages();

-- count number of pages
ttl_pages = Table.Count(all_pages);

-- reset the comboBox content
ComboBox.ResetContent("yourCombo");

--Populate your Combo Box (starting from page 2 as page1 is where your combo box is located)
ComboBox.SetUpdate("yourCombo", false);

--Define string of pages not to find
strSearchMe = "Admin, Secret, EasterEgg, Yadayadayada, George, Kramer";

for i = 1, ttl_pages do
--list of pages not to show. As long as the name is not found (-1) in the string
-- these pages will not be displayed.
if String.Find(strSearchMe, all_Pages[i], 1, false) == -1 then
ComboBox.AddItem ("yourCombo", all_pages[i],"");
end
end
ComboBox.SetUpdate("yourCombo", true);

Rikard
05-24-2005, 02:58 PM
Thanks for the replies I will play with it for a while now.

I’m amazed every time I take a look in this forum an sees all the fast and explaining replies.
I think I will start an AMS religion :rolleyes

yosik
05-24-2005, 03:56 PM
Yes, you're right TJ. A correct addendum. Thanks
Yossi