Indexing by the specified field

This forum is for eXpress++ general support.
Post Reply
Message
Author
User avatar
Eugene Lutsenko
Posts: 1649
Joined: Sat Feb 04, 2012 2:23 am
Location: Russia, Southern federal district, city of Krasnodar
Contact:

Indexing by the specified field

#1 Post by Eugene Lutsenko »

Hi!

I would like to sort the table by field name (or number) which is set as a variable value.

Now used this option:
INDEX ON STR(99999999.9999999-FIELDGET(ff),19,7) TO Mrk_funi

But it turned out that it doesn't work for numeric fields that specify the integer values 0 and 1. In the other cases it works fine.
Sort numeric integer error does not cause, but the result is wrong.

Tried this:
mFN = FIELDNAME(ff)
INDEX ON STR(99999999.9999999-&mFN,19,7) TO Mrk_funi

But it throws error.

And such a simple option is also not working:
INDEX ON STR(99999999.9999999-FIELDNAME(ff),19,7) TO Mrk_funi

The data type in the field numeric N7

Error occurs when a field numeric integer. if you make the decimals no zeros, then everything is working fine.

Which In Alaska is the data types for databases: the "Integer" and "Short integer"?
Attachments
Безымянный.jpg
Безымянный.jpg (69.77 KiB) Viewed 6925 times

skiman
Posts: 1199
Joined: Thu Jan 28, 2010 1:22 am
Location: Sijsele, Belgium
Contact:

Re: Indexing by the specified field

#2 Post by skiman »

Hi,

You can use a function for this.

Code: Select all

INDEX ON STR(99999999.9999999-FIELDGET(ff),19,7) TO Mrk_funi
You can change this to:

Code: Select all

INDEX ON calculatevalue(ff) TO Mrk_funi
In the function you can controle everything.

Code: Select all

function calculatevalue(ff)
local nValue := fieldget(ff)
if nValue
...
else
....
endif
return STR(99999999.9999999-nValue,19,7) 
Best regards,

Chris.
www.aboservice.be

User avatar
Eugene Lutsenko
Posts: 1649
Joined: Sat Feb 04, 2012 2:23 am
Location: Russia, Southern federal district, city of Krasnodar
Contact:

Re: Indexing by the specified field

#3 Post by Eugene Lutsenko »

Thank you very much! Based on this, I did what I need, and everything works fine:

Code: Select all

FUNCTION CalculateValue(ff)
local nValue := FIELDGET(ff)

mKey = ''

IF FIELDDECI(ff) = 0                    // Целые
   mKey = STR(99999999-nValue,15)
ELSE
   mKey = STR(99999999.9999999-nValue,15,7)
ENDIF

RETURN(mKey)


Post Reply