Help

Source code related resources

Moderator: Rathinagiri

zorpavns
Posts: 22
Joined: Tue Apr 23, 2013 10:43 am
DBs Used: DBF, SQL
Location: Novi Sad, Serbia

Help

Post 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
Marin
Posts: 33
Joined: Tue Dec 20, 2016 1:39 pm
DBs Used: DBF
Location: Bulgaria, Sofia
Contact:

Re: Help

Post by Marin »

Hi zorpavns,

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

Regards,
Marin
zorpavns
Posts: 22
Joined: Tue Apr 23, 2013 10:43 am
DBs Used: DBF, SQL
Location: Novi Sad, Serbia

Re: Help

Post by zorpavns »

What to do when a combined index is composed of letters and numbers
Marin
Posts: 33
Joined: Tue Dec 20, 2016 1:39 pm
DBs Used: DBF
Location: Bulgaria, Sofia
Contact:

Re: Help

Post 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...
zorpavns
Posts: 22
Joined: Tue Apr 23, 2013 10:43 am
DBs Used: DBF, SQL
Location: Novi Sad, Serbia

Re: Help

Post by zorpavns »

Example index

vrs=Ch2
Sal=Numeric 19,2

vrs+str(sal,19,2)
trmpluym
Posts: 303
Joined: Tue Jul 15, 2014 6:52 pm
Location: The Netherlands

Re: Help

Post 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
ROBROS
Posts: 256
Joined: Thu May 25, 2017 6:30 pm
DBs Used: DBF
Location: D 83071 Stephanskirchen

Re: Help

Post 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
edk
Posts: 909
Joined: Thu Oct 16, 2014 11:35 am
Location: Poland

Re: Help

Post by edk »

Try instead of str () to use a strzero ()
User avatar
BeGeS
Posts: 125
Joined: Fri Jul 14, 2017 10:45 am
DBs Used: DBF
Location: La Mancha, Spain

Re: Help

Post 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)
I get by with a little help from my friends
zorpavns
Posts: 22
Joined: Tue Apr 23, 2013 10:43 am
DBs Used: DBF, SQL
Location: Novi Sad, Serbia

Re: Help

Post by zorpavns »

Greeting.
You should need help

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