A second set of eyes?

I am doing an overhaul on one of my Xojo web apps and I can’t seem to figure out why adding a row to a WebPopupMenu is not working. It didn’t start out being “one of those days” but is sure turning into one.

I am using a method within a webdialog that is fired upon showing the webdialog. I have already broken it out of the loop I was using to identify what the deal is/was (good ole divide and conquer - from my pl/sql and Oracle 8 days). Still no luck, can someone lend a “second set of eyes” and tell me what I am missing?

wpu = WebPopUpMenu

wpu.AddRow("some value")
wpu.RowTag(wpu.Listindex) = 1

It errors on the rowtag call with an outofbounds exception.


Tried listcount -1with no luck. Looking to use the value not the display for the webpopupmenu control.

row numbers start at 0 so row 1 doesn’t exist yet.

The value for the rowtag is what I am attempting to set to 1.
recordset/dictionary what ever…
1, “Some string value”
2, “Another string value”
3, “Yet another string value”

Looking to store the ID (1,2,3) in the rowtag and the string value in the row using AddRow()

I am attempting to load a webpopupmenu the way I would with a listbox but without “lastindex”

wpu.ListIndex is -1. What else do you expect it to be???

Please learn to use the debugger.

You could use

wpu.RowTag( wpu.IndexOfRow(“some value”) ) = 1

This works fine


wpu.AddRow(“some value”)
wpu.AddRow(“some value 2”)
wpu.AddRow(“some value 3”)

wpu.RowTag( wpu.IndexOfRow(“some value 2”) ) = 1

wpu.ListIndex = wpu.IndexOfRow(“some value 2”)[/code]

Ok, I guess I am having one of those days.

wpu.Addrow(“Some Text”)
// expecting the webpopupmenu to now contain 1 row (yes,0 based)

wpu.rowtag(wpu.listcount-1) = 1
// expecting the control to set the value of the first row’s rowtag to 1
// wpu.listcount = 1, then -1 because rows start at 0

As far as the debugger, the value listcount value is not displayed in the debugger for a webpopmenu.

I appreciate anyone willing to help but if you are just wanting an opportunity to bash someone, save mine and your time and don’t bother.

Markus, Looks like you replied twice before my last reply. Last reply may seem a little harsh.
Under a time crunch and frustrated with scope creep.

You are working on the mistaken assumption that list count or list index contain what you want them to contain. They don’t.

The desktop has LastIndex - the web version sadly does not.

Yes, aware of where lastindex is available.

I do not understand your comment about mistaken assumption, per the docs, “Used to get the number of items in the list.” If setting the the value of rowtag during initial population, is it bad to use listcount? I do understand that listindex is for retrieving current row of the control.

I fired up another quick project in Xojo with just one control on a page. What I was attempting in the other project works as expected.

webpopupmenu open

me.addrow("value one")
me.RowTag(me.listcount-1) = 1
me.addrow("value two")
me.RowTag(me.listcount-1) = 2

I am then able to retrieve the value of the rowtag. Looks like my issue lies elsewhere. ugh!!!

Kudos to you Markus!
So far 52 views and you are the only one that has attempted to assist.

[quote=315993:@Bob Sellers]Yes, aware of where lastindex is available.

I do not understand your comment about mistaken assumption, [/quote]

I thought you tried to use ListIndex as LastIndex.

Ouch. Good luck!

[quote=315996:@Bob Sellers]Kudos to you Markus!
So far 52 views and you are the only one that has attempted to assist.[/quote]
Wayne did too and was right - your code has a ListIndex of -1 which results in the OutOfBounds exeption you are seeing. So your problem might be right there.

Sure I’ll give Wayne credit too.
Although the I could see the following being more useful:
“you are using listindex. try using listcount-1 when using a popupmenu in this manner”

And if the comments were read, I provided a note stating that listcount wasn’t working with it either.

Thanks for the replies.

Anyway, off to try to figure out what the … is wrong with it.