Subject |
Re: indexing with character numbers |
From |
Charlie <tm@tc.com> |
Date |
Sun, 26 Jan 2025 10:01:40 -0500 |
Newsgroups |
dbase.getting-started |
Thanks for your help guys.
I tried this...
i tried indexing on val(id) and it didn't seem to work. So I tried indexing on a field that was already numeric and it worked alone. But when I did this...
index on category+numeric field tag test the numeric field was not in order.
and have it work?
Mervyn Bick Wrote:
> 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.
>
>
>
|
|