﻿Alaska Software Inc. - Creating Indexes with numeric values
Alaska Software Inc. - Creating Indexes with numeric values
AuthorTopic: Creating Indexes with numeric values Carlos A Beling Creating Indexes with numeric values
on Wed, 11 Sep 2019 17:16:06 -0300
```Good afternoon.
I need to create an index like this (cName + iif(nNumber > 0, '+' +
Strzero(nNumber, 10), StrZero(nNumber, 11)).
The problem is that StrZero(-1, 11) is shown LESS than StrZero(-2, 11)
and I think that is nopt true.
Please, how can Iwrite the correct expression for to get the correct
result in ascending and descending order?

Fraternally
Beling``` Luiz E. Penna FernandesRe: Creating Indexes with numeric values
on Thu, 12 Sep 2019 10:31:36 -0300
```If there is a known limit to the negative values of nNumber, you could
try, for example, (cName + StrZero(1000 + nNumber)).

On 2019-09-11 17:16, Carlos A Beling wrote:
> Good afternoon.
> I need to create an index like this (cName + iif(nNumber > 0, '+' +
> Strzero(nNumber, 10), StrZero(nNumber, 11)).
> The problem is that StrZero(-1, 11) is shown LESS than StrZero(-2, 11)
> and I think that is nopt true.
> Please, how can Iwrite the correct expression for to get the correct
> result in ascending and descending order?
>
> Fraternally
> Beling``` Carlos A Beling Re: Creating Indexes with numeric values
on Thu, 12 Sep 2019 11:42:34 -0300
```Hi Luiz:
good day.
The solution is easy:
(cName + ' ' + StrZero(nNumber))
The problem that remains is that StrZero(-1) is always considered being
less than StrZero(-2).

Fraternally
Beling

Em 12/09/2019 10:31, Luiz E. Penna Fernandes escreveu:
> If there is a known limit to the negative values of nNumber, you could
> try, for example, (cName + StrZero(1000 + nNumber)).
>
> On 2019-09-11 17:16, Carlos A Beling wrote:
>> Good afternoon.
>> I need to create an index like this (cName + iif(nNumber > 0, '+' +
>> Strzero(nNumber, 10), StrZero(nNumber, 11)).
>> The problem is that StrZero(-1, 11) is shown LESS than StrZero(-2, 11)
>> and I think that is nopt true.
>> Please, how can Iwrite the correct expression for to get the correct
>> result in ascending and descending order?
>>
>> Fraternally
>> Beling
>``` Andreas Gehrs-Pahl Re: Creating Indexes with numeric values
on Thu, 12 Sep 2019 10:52:52 -0400
```Carlos,

>I need to create an index like this (cName + iif(nNumber > 0, '+' +
>Strzero(nNumber, 10), StrZero(nNumber, 11)).

>The problem is that StrZero(-1, 11) is shown LESS than StrZero(-2, 11)
>and I think that is nopt true.

Actually, it is true. The ASCII code for the digit "1" is 49 and the ASCII
code for the digit "3" is 51. As you compare characters (rather than
numerical values), "1" is less than "3" as is: "anything1" is less than
"anything3", as long as "anything" is the same in both cases, which it is

You can do exactly what Luiz suggested, though:

>If there is a known limit to the negative values of nNumber, you could
>try, for example, (cName + StrZero(1000 + nNumber)).

And as you used StrZero(n, 11) you also have your known limit on positive
and negative numbers.

>Please, how can Iwrite the correct expression for to get the correct
>result in ascending and descending order?

The following should give you the correct sort order in both ascending and
descending order:

(cName + StrZero(10000000000 + nNumber, 11))

Basically, use a 1 with as many Zeros as the length of the Numerical Field
and use (1 + the length of the Numerical Field) for the <nLength> parameter
of the StrZero() function.

Hope that helps,

Andreas```

```Andreas Gehrs-Pahl
Absolute Software, LLC

phone: (989) 723-9927
email: Andreas@AbsoluteSoftwareLLC.com
web:   http://www.AbsoluteSoftwareLLC.com Andreas Gehrs-Pahl Re: Creating Indexes with numeric values
on Thu, 12 Sep 2019 11:02:56 -0400
```Carlos,

By the way, it doesn't matter if you use str() or  StrZero(), as the result
is the same. "-00001" is less than "-00002", and "    -1" is also less than
"    -2" -- no matter if you use Zeros or Spaces as your prefix.

The same is true for the fix:
(cName + str(10000000000 + nNumber, 11))

will work as well as:
(cName + StrZero(10000000000 + nNumber, 11))

Andreas```

```Andreas Gehrs-Pahl
Absolute Software, LLC

phone: (989) 723-9927
email: Andreas@AbsoluteSoftwareLLC.com
web:   http://www.AbsoluteSoftwareLLC.com Carlos A Beling Re: Creating Indexes with numeric values
on Thu, 12 Sep 2019 13:04:45 -0300
```Hi Andreas:
good day.
Many many thanks again.

Fraternally
Beling

Em 12/09/2019 12:02, Andreas Gehrs-Pahl escreveu:
> Carlos,
>
> By the way, it doesn't matter if you use str() or  StrZero(), as the result
> is the same. "-00001" is less than "-00002", and "    -1" is also less than
> "    -2" -- no matter if you use Zeros or Spaces as your prefix.
>
> The same is true for the fix:
> (cName + str(10000000000 + nNumber, 11))
>
> will work as well as:
> (cName + StrZero(10000000000 + nNumber, 11))
>
> Andreas
>```