How to test if a character value is > 255?

I have troubles sorting a text file using a ListBox.

For testings, I had a crazy idea: using Xojo to remove eventual gremlins and I saw a difference.

So I coded a check / report for gremlins characters (value only > 255), but none was found.

Thus my question.

I used:

If AscB(Mid(AnEntry, Char_Pos,1)) > 255 Then

And place the whole AnEntry string into a TextArea. Once the (long) decoding is over, TextArea is empty, so I suppose my test is wrong.

Nota: because I know my text can hold sticke spaces (160), I replace them all before (While … Wend) the test.

Ideas ?

ChrB is from 0 - 255 so you are trying to test over 255 which is probably never gonna happen.
I think you want to check for 0-31 (inclusive), these characters are always invisible in text editors.
see here:

Chr >= 128 are ASCII extended (or UTF-8)

Const invisible_lower_bound = 0
Const invisible_upper_bound = 31
Var character As Integer = AscB(Mid(AnEntry, Char_Pos, 1))
If character >= invisible_lower_bound  And character <= invisible_upper_bound  Then
// Remove or skip this character from printing
End If

HI Derk,

thanks for your answer.

I think you want to check for 0-31 (inclusive), these characters are always invisible in text editors.
My fault, I do not say where the text come from. These are file names, so no ASCII 0 - 31.
No one (or he do not care) ever told him that the notion of “Extended ASCII” does not exists. :joy:

There is definitely something in my text as I already wrote in my original text because Xojo IDE remove something and the ListBox Sort works fine.

When I sort on a specific column, I get a strange behavior on Column(0) who holds the magazine name and issue number. In some cases, the story was reprinted some years after the original and the lower issue number Row sometimes appears after the higher issue number. This have no sense: the clicked column group Cells with the same contents, but a second sort is done to produce that.
The original text shows the magazine with ascending numbers (1 to 481 in this case).

Back to Xojo:
I will check if I can do something with a MemoryBlock.

Talking about MemoryBlock: the doc page talks about 32-bit applications…
The example (link below) do not have any sense (to me): it display how to create a MemoryBlock with 8 Bytes from a 8 Bytes MemoryBlock !

I used a MemoryBlock (faster), but no, IO do not found (yet) strange behavior.

Sorted Strings (relevant Column only):
Mandrake 341r (023)
Mandrake 023
Mandrake 024
Mandrake 342r (024)

I was awaiting:
Mandrake 023
Mandrake 024
Mandrake 341r (023)
Mandrake 342r (024)

and I still do not know why.

Remember: the sort is done on another Column. The data in that column for the 4 lines above is the same. I do not have implemented any custom Sort for any other Column.

Ideas ?

Inspect the strings in the debugger. Look at the bytes following “Mandrake”.

That is not guaranteed.

Hi Tim,

sorry, here’s a better statement:

These are file names I typed before using the files, so no ASCII 0 - 31 allowed by macOS’ Finder…

Watching strings as Hex: I forgot to do that… I will do.


As previously mentioned, AscB() returns the value of a byte which can never be greater than 255. Characters with codepoints higher than 255 are multi-byte. So you need to use the Asc() function instead of AscB().

Still not guaranteed. I’ve managed to insert control characters while typing.

I do not know how to do that (yet).

Remember: the sort is done on another Column.

The order you want is the one governed by THIS column.
Clearly the thing that is causing a strange order is in ‘the other column’
The most likely cause is that ‘the other column’ does not actually contain the same text.
Maybe there are simply 2 spaces between Mandrake and 341r

No, one space only. I removed “r (023)” and “r 024)” and get the same strange behavior.

When no special sorting code is set (using default), and you have duplicate cells in the Column you click for Sort, a secondary sort is done, but I do not know the criteria nor what Column is/are used.

I will let time run some days and come back (next week)… I may come with a new look… This is the good side of having hazardous memory…

I may forgot to say that all Rows appeared from issue 1 thru issue 451. If the Sort is done on a single column, the one I clicked on, the returned order in the Magazine Issue Number will be the lower value first, until the higher value (when some Cells in the sorted column contains the same String).
When I Sort Column(0) - the Magazine Issue Number - the ListBox contents is sorted numerically (1 thru 451 or 451 thru 1).

Now, I may be wrong all the line…

I wish I could follow more of this.

If you are not getting the data in the order you want by clicking a column, get the data from a database using a sort that operates on two fields.
Populate the listbox using the sorted dataset.

select * from stuff order by field1,field2;

Thank you Jeff.

That is what I am doing now.

Never assume something you don’t know how to do is just impossible to do :wink:

It’s never on purpose and only discovered after the fact when things don’t work the way I expected.

Back home yesterday (and a reboot later), I continued to add code to store the text in a data base (SQLite) and in a run, I looked what I had on the screen (instead of the generated .sqlite file and discovered the data appears correctly.

I have to check once more - just in case I was not dreaming - and understand my troubles in what is stored in the .sqlite file to be sure there is no more a problem.

I found correct entries and other entries.

Some of the other entries have a difference in the story title (not the magazine/issue #).

With the Data Base creation, I spotteds some errors in my text data ( instead of 4 for example - sqlite does not liked that - or standard single quote instead of curly single quote ).

A last clue is the Memory: too many application that are running together, maybe. I closed some and try again.

Last news in that subject (a work-aound):

It tooks me time, but after introducing some bugs in the code, I changed the structure of the Method, add a call to read the data and write them in a SQLite data base, then Add a button and code to read and sort based on two columns.

Results: far clear code / working feature.

Now I get the similmar entries displayed from the older magazine number to the latest number.
I had a moment yesterday when I was at home (without internet to search how to sort a data base on two Columns), then recall that I certainly have the SQLite documentation (as html) and found it (so simple, but I forgot it).
Now, I have my data displayed on the correct order.

As Droopy said “You know what ? I’m happy !”

Forum for Xojo Programming Language and IDE. Copyright © 2021 Xojo, Inc.