Fill a Listbox from Thread

The Problem is … R cant be null in thos array
Error Number is 123

TextInputStream can raise an IOExceptionError. Did you use the example with try ?

I had that during months. I used the try …/… end try example and still get the exception until I clear the old code and wrote a new one (it was an error 'cause I cannot compare the new code to the old one) and now {I cross my fingers} I do not get that IOException anymore.

[quote=292389:@Sascha Mierke]The Problem is … R cant be null in thos array
Error Number is 123[/quote]
If there is an error number, maybe there is also an error message?

TextInputStream.Open will raise IOException when R is a directory or not exist. But, in your case errorNumber=123 means that the file has invalid name. So, to avoid the exception, you can add

  If R.Exists Then
    tocInput = TextInputStream.Open(R)
    toc = tocInput.ReadAll
    tocInput.Close
  End If

or for more complete solution

  If (Not R.Directory) And (R.Exists) Then
    tocInput = TextInputStream.Open(R)
    toc = tocInput.ReadAll
    tocInput.Close
  End If

Hm i really dont understand this, when i wrote a msgbox r.nativepath in this code… the msgbox shows me the valid path to the file to open, this file exists, so how can it have a invalid name? Is that from the cmd shell?

With the slow Xojo search the same code works :wink:

Use shellPath instead of nativePath. On Windows it is what the shell is expecting.

[quote=292411:@Asis Patisahusiwa]TextInputStream.Open will raise IOException when R is a directory or not exist. But, in your case errorNumber=123 means that the file has invalid name. So, to avoid the exception, you can add

  If R.Exists Then
    tocInput = TextInputStream.Open(R)
    toc = tocInput.ReadAll
    tocInput.Close
  End If

or for more complete solution

If (Not R.Directory) And (R.Exists) Then tocInput = TextInputStream.Open(R) toc = tocInput.ReadAll tocInput.Close End If [/quote]

Tried the last one, it looks like it dont think this is a file to read…so it thinks R is a directory? But why

No idea. Maybe we’ll have better understanding if you can provide simplest workaround/environment in small project contains that issue. Or, you can tell us what’s the string path that cause the issue?

tried to create a example with this:

[code] Dim tocList() as String
tocList.Append(“C:\Tools\Wow\Interface\Addons\AtlasLoot\AtlasLoot.toc”)

for i As integer = 0 to tocList.Ubound
Dim R as FolderItem = GetFolderItem(tocList(i).ToText)
msgbox R.NativePath
next[/code]

this is working…

the same thing in the righ project isnt working



This makes completely no sense to me anymore… the array tocList is filled with strings and xojo things R could be nil? Maybe something is wrong with that shell result output…encoding or something?

Best example:

you see it here… f cant be nil

Are you sure that Chr(10) is the correct end of line?
If not there maybe invisible character(s) in the array after the .toc extension.
Use EndOfLine instead, this is operating system independent.
http://documentation.xojo.com/index.php/EndOfLine

Ok, I found the error. There are two solutions:

First, Replace this line

dim lines() as string = tocSearch.Result.Split( Chr( 10 ) )

with

dim lines() as string = tocSearch.Result.Split(EndOfLine.Windows)

Or Second , replace this

tocList.Append(lines(l))

with

tocList.Append(ReplaceLineEndings(lines(l), ""))

You have the error because of the path contains 0A in the end.

Edit:

CRLF in the end of each toclist item

'read lines in a array dim lines() as string = tocSearch.Result.Split(EndOfLine) for i as integer = 0 to lines.Ubound -1 tocList.Append(lines(i).ToText) next

i tried it now like this and it works… wow so the shell a bit faster but really stupid to use. On mac/linux i have to call an other command and i dont know if the EndOfLine is working there :frowning:

But thank you all for the help :slight_smile:

Yes it does.
See the documentation as I mentioned before.
http://documentation.xojo.com/index.php/EndOfLine