I have TextArea1 withs some data about 9494 lines… FirstName, Lastname, Address, Tel, etc
I would like to sort by FirstName, each line starts with FirstName.
I have this code…
dim myArray() as string
Dim i, j as integer
Dim TotalnumberOfEntries as Integer
TextArea1.Text = ReplaceLineEndings(TextArea1.Text, EndOfLine.Macintosh)
TotalnumberOfEntries = CountFields(TextArea1.Text, EndOfLine.Macintosh)
Label4.Text = Str(TotalnumberOfEntries) + " entries"
myArray() = Split(TextArea1.Text, EndOfLine.Macintosh)
myArray().Sort
For i = 0 to TotalnumberOfEntries-1
TextArea2.Text = TextArea2.Text + Trim(myArray(i)) + EndOfLine.Macintosh
j = j+1
Label6.Text = Str(j)
next i
but it does not do the full list of approx 9494 lines it does the first 5566 lines.
What could be the problem there and how can I fix it?
does you data REALLY have the MacIntosh end of line? 0x0D?
most recent files either have the UNIX (0x0A), or WIndows (0x0A0D)
dim myArray() as string
Dim i, j as integer
Dim TotalnumberOfEntries as Integer
TextArea1.Text = ReplaceLineEndings(TextArea1.Text, EndOfLine.Macintosh)
myArray() = Split(TextArea1.Text, EndOfLine.Macintosh)
TotalnumberOfEntries = myArray.UBound
Label4.Text = Str(TotalnumberOfEntries) + " entries"
myArray().Sort
For i = 0 to TotalnumberOfEntries-1
TextArea2.Text = TextArea2.Text + Trim(myArray(i)) + EndOfLine.Macintosh
j = j+1
Label6.Text = Str(j)
next i
but contrary to popular belief… todays Mac DO NOT use that end of line in normal file activity.
the EndofLine.Macintosh was standard for Macs running OS9 and before… this changed years ago with OSX
what value does TotalnumberOfEntries have using my example?
If it is 5566 then that is truly all the “lines” you have. Remember if you have lines that WRAP in your textarea, they are just long lines… so you might want to think in terms of “paragraph” …
When I created the data I used car(13) as the end of line
So I just added a new line…
TextArea1.Text = ReplaceAll(TextArea1.Text, Chr(13), EndOfLine.Macintosh)
above
TextArea1.Text = ReplaceLineEndings(TextArea1.Text, EndOfLine.Macintosh)
to hopefully correct that problem
I also checked where the sort finished and deleted a few lines above and below that point.
I am still getting approximately 5566 sorted lines, it varies every time bt it is always in the 5500/5600 range.
A TextArea is not going to honor your EndOfLine, it’s going to use whatever it uses (&u10 all the time, I think, but maybe &u0D+&u10 on Windows). In other words, replacing the line endings, then sticking it back into the TextArea won’t do what you think.
Try something like this instead:
dim s as string = TextArea1.Text
s = ReplaceLineEndings( s, EndOfLine )
dim myArray() as string = s.Split( EndOfLine )
myArray.Sort
TextArea1.Text = join( myArray, EndOfLine )