The following code is a stripped down version of an actual code used in a project where I have troubles (and I do not know why).
After some minutes, I wanted to know why I have an empty line at the LMistBox start. After I Started to investigate, I watched carefully the loop in the debuger and
and I found the following:
The first pass in the For Loop store an empty ASCII string in One_Line, according to the Debugger. The second pass in the Loop store my text in One_Line and assign to it an UTF-8 encoding. It looks like I found something.
[code] Dim Text_UTF As String
Dim LoopIdx As Integer
Dim LineCnt As Integer
Dim One_Line As String
// Delete the previous contents
LB.DeleteAllRows
// The EndOfLine character is LF on OS X
Text_UTF = “Simple text, one line only.” + EndOfLine // I have another line here, this one is for the test
// How many lines in the dropped text ?
LineCnt = CountFields(Text_UTF,EndOfLine) - 1
// Scan the Text_UTF contents
For LoopIdx = 0 To LineCnt
// Get a line
One_Line = NthField(Text_UTF,EndOfLine,LoopIdx)
// Add it to the ListBox
LB.AddRow Str(LoopIdx) // *
// To Avoid 1, Infinite Loop
If UserCancelled Then Exit
Next
[/code]
Notes:
I created a brand new project,
I added a ListBox called LB
I added an Event (Open) in Window1 and place the code there.
I do not have nothing else in the project that I do not even save (what for ?)
Environment:
MacBook Pro 2011-11
OS X 10.9.5
Xojo 2014r2.1
TextEdit (Apple),
Safari (Apple).
Another project is loaded in the IDE (I needed to steal some code from it).