Hi, I have a problem I can’t figure out. (I’m on Xojo 2017 r3)
I googled for this but can’t find it.
I have a listbox, populated with url’s
I do the following:
get the index for the selected row, pass it to the listbox to get the content and load the selected url
but it doesn’t work
[code]dim theIndex as integer
theIndex = listURL.ListIndex
dim theURL as string
theURL = listURL.List(theIndex)
msgbox(theURL) '===> this shows the selected URL just fine
HTML.LoadURL(“https://mywebsitehere.com”) '===> this does work
HTML.LoadURL(theURL) '===> this however doesn’t work[/code]
[code]dim theIndex as integer
theIndex = listURL.ListIndex
dim theURL as string
theURL = listURL.List(theIndex)
msgbox(theURL) '===> this shows the selected URL just fine
HTML.LoadURL(“https://mywebsitehere.com”) '===> this does work
HTML.LoadURL(theURL) '===> this however doesn’t work[/code]
you should do check if the ListIndex <> -1
[quote]
If no item is selected, ListIndex returns -1. If the ListBox is in multiple-row selection mode, then the number of the lowest selected row is returned. For example, if rows 1, 3, and 4 are selected, ListIndex returns 1.
[quote=462440:@Rick Araujo]The pointed solution says that there is/was a bug with HTML.LoadURL( aStringValue ) but it works with HTML.LoadURL( aTextValue )
So the proposed workaround was HTML.LoadURL( aString.ToText() )[/quote]
Strange (because a String should work just fine). But thank you
OK, I’m sorry: I had marked the demofile as answer, but it was too soon. I saw it in action, and believed the “ToText” (inside the brackets, as opposed to the earlier answer with ToText outside the brackets) was the solution. I couldn’t test it out though as I really needed to work on something else. Now that I have tested it, it isn’t the solution …
However, the sample code did point me in the right direction.
I saw the code from Tanner Lee, and he populated the listbox row with a literal string. And everything worked …
I didn’t notice huge differences with my code, so I guessed the problem wasn’t my code, but my variable string.
I get the strings from reading each line in a textfile and adding them to the listbox as a row.
Adding — before and after the string showed me there was a line ending I wasn’t aware of.
In the shell I now trim the line ending with " tr -d ’
’ " before passing it to listbox and all works fine …
So a big thanks for all the help, I really appreciate it. I just started with Xojo (after years of Applescripting everything), I’m totally excited, and it’s great to see there is a nice community with friendly people who are willing to help each other out
That’s what I thought at first too. The debugger showed a simple UTF8 string without any gremlins. But the htmlviewer wouldn’t open it. Added .ToText to the variable and it worked.
In light of Chris’ comment above I removed the .ToText call, and now it worked as documented.
Chalking this up to a cache issue. Have 9 versions of RS/Xojo installed.