Page 1 of 1

function who return the length of an numeric item from the dictionnary

Posted: April 26th, 2017, 12:21 pm
by thierryt
Good morning,
please i need the function who return the length of an numeric item from the dictionnary. i know that the length of alpha item is return by the function LENGTH, but what about numeric item ?
Thanks

Re: function who return the length of an numeric item from the dictionnary

Posted: April 26th, 2017, 1:12 pm
by josh
Do you need the max length allowed for the dictionary variable or the length in digits of the number of the current value?

Re: function who return the length of an numeric item from the dictionnary

Posted: April 26th, 2017, 4:10 pm
by thierryt
Hi Josh,
i need the max length allowed for the dictionnary variable

Re: function who return the length of an numeric item from the dictionnary

Posted: April 26th, 2017, 8:47 pm
by Saint
Not sure what you mean.. Lets say if you have an entry of 333, you want to return the length as 3, and if you have 23456, you want to return the length as 5. Is that what you need a function for?

Re: function who return the length of an numeric item from the dictionnary

Posted: April 27th, 2017, 8:49 am
by Gregory Martin
If you don't have a value set, you can use the maxvalue function, which will return the highest value supported by the field. This should get you the length:
length(maketext("%d",maxvalue(ITEM_NAME)));

Re: function who return the length of an numeric item from the dictionnary

Posted: April 27th, 2017, 1:32 pm
by thierryt
Hi Martin,
It is exactly what i wanted,
Thanks a lot.
Please can i have the function who return the number of cases of a data file ?

Re: function who return the length of an numeric item from the dictionnary

Posted: April 27th, 2017, 7:23 pm
by Gregory Martin
That function doesn't exist in CSPro 6.3. In CSPro 7.0, which is now in beta, you can write:
keylist(DICT_NAME);
That will return the number of cases.