Subject |
Re: indexing with character numbers |
From |
Mervyn Bick <invalid@invalid.invalid> |
Date |
Sat, 25 Jan 2025 23:14:46 +0200 |
Newsgroups |
dbase.getting-started |
On 2025/01/25 21:15, Charlie wrote:
> I am working on a new project. There is a field which is character. I want it to act as if it is a number by order. instead of 723 coming before 98, I would like them in numerical order. I am importing some of the data from a spreadsheet and it's easier if all rows are character from my experience.
>
> Would I be better off to just bite the bullet and go with a numeric field instead of character? Is there some way to have a character to index like numbers?
>
> Thanks for any help!
The values in character fields are left-justified in the field. To be
able to order them in numerical order you need to left-pad the strings
with spaces i.e right-justify the values.
use whatever exclusive
set index to
replace all charfld with str(val(charfld),10,0)
index on charfld tag tagname
use
In the str() function use the actual width of the character field
instead of 10 used in the example.
Mervyn.
|
|