Help
Moderator: Rathinagiri
Help
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
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
-
- Posts: 231
- Joined: Tue Jul 15, 2014 6:52 pm
- Location: The Netherlands
- Has thanked: 6 times
- Been thanked: 19 times
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
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
- BeGeS
- Posts: 124
- Joined: Fri Jul 14, 2017 10:45 am
- DBs Used: DBF
- Location: La Mancha, Spain
- Has thanked: 33 times
- Been thanked: 21 times
I would create this function:
Your index:
vrs+NEGATEX(sal)
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
vrs+NEGATEX(sal)
I get by with a little help from my friends