Page 1 of 2

Help

Posted: Sun Feb 18, 2018 12:44 pm
by zorpavns
Help
How to index positive and negative numbers. So put them in a rising order.

When the number is converted to a string, it disappears like this:

-10000.00
20000.00
-5000.00
5000.00
Does anyone have an idea of ​​how to fit properly.

Thanks in advance

Re: Help

Posted: Sun Feb 18, 2018 12:56 pm
by Marin
Hi zorpavns,

Try using:
INDEX ON VAL(char_field) to File_NTX.

Regards,
Marin

Re: Help

Posted: Sun Feb 18, 2018 12:58 pm
by zorpavns
What to do when a combined index is composed of letters and numbers

Re: Help

Posted: Sun Feb 18, 2018 1:20 pm
by Marin
zorpavns wrote: Sun Feb 18, 2018 12:58 pm What to do when a combined index is composed of letters and numbers
Please kindly give an example of your index key resulting data. Up to now we were talking about numbers only, i guess...

Re: Help

Posted: Sun Feb 18, 2018 1:32 pm
by zorpavns
Example index

vrs=Ch2
Sal=Numeric 19,2

vrs+str(sal,19,2)

Re: Help

Posted: Sun Feb 18, 2018 1:34 pm
by trmpluym
Zorpavns,

There is a simple solution for this problem. You can simply add a large number to compensate the largest possible negative number.

For example when the field has got 4 positions add 99999 (five times 9).

STR(NumField+99999)

The index would be always positive and the sort order is correct.

Theo

Re: Help

Posted: Sun Feb 18, 2018 1:43 pm
by ROBROS
Hi Zorpavns,

"Mixed" index: persnr is a "C", character field, date is "D", date field.

My index: index on persnr+dtos(date) to indexfile.

Regards
Robert

Re: Help

Posted: Sun Feb 18, 2018 2:56 pm
by edk
Try instead of str () to use a strzero ()

Re: Help

Posted: Sun Feb 18, 2018 3:14 pm
by BeGeS
I would create this function:

Code: Select all

FUNCTION NEGATEX(NUMERO)
LOCAL RESUL
 IF NUMERO<0
    RESUL:= "-" + STR(ABS(NUMERO),18,2)
 ELSE
    RESUL:= STR(NUMERO,19,2)
 ENDIF
RETURN RESUL
Your index:

vrs+NEGATEX(sal)

Re: Help

Posted: Tue Jul 31, 2018 10:03 pm
by zorpavns
Greeting.
You should need help

How to connect to Microsoft sql server and retrieve data
Thanks a lot