ctarton1
6th April 2007, 12:38
Hi,
Is there a function to have the number of array filled elements?
Thanks in advance,
Carmelo
bdittmar
6th April 2007, 13:24
Hi,
Is there a function to have the number of array filled elements?
Thanks in advance,
Carmelo
Hello,
please be more specific with your request.
Regards
mark_h
6th April 2007, 13:42
Yes - please be more specific. Are you talking on a form? Are you talking about a script array?
ctarton1
6th April 2007, 19:39
I am talking about script array. For example, I defined an array with 100 element. The script only filled 10 elements. I passed this variable as a function argument and I want to make operations only up to the filled elements of the array.
mark_h
6th April 2007, 20:41
Can you post the code you are talking about? Typically when I am filling an array I track which element is being loaded. So then if I pass this somewhere I can always just process the filled array. Or in some cases I just stop processing at the first empty (or 0) element.
Hitesh Shah
7th April 2007, 15:56
U should have a separate long counter variable to keep track of it . There is nothing in Baan to keep track of filled or for that matter to indicate the number of elements in an array dynamically created (with alloc.mem) once its allocated . U need to use separate variables to keep track of it .
en@frrom
13th April 2007, 14:49
You can also just loop through the array and check for each element if the array is filled, and count up. Performance-wise this is not so bad, as long as you don't do this continuously...
_Ralph_
13th April 2007, 18:59
In LN I use the
qss.search
u can search for it on your programers guide =)
Hitesh Shah
14th April 2007, 16:07
If the array is sorted with qss.sort and we use the flag QSS.SRC.IS.SORTED , qss.search gives very fast results .It is true that qss.sort also has some overhead . But if the proportion of grouped records to extracted records is very less , this sort overhead is insignificant compared to significant gains of binary search .
e.g.
if the number of distinct elements in an array is 100 , then maximum number of iterations to search the item could be 100 in linear search , whereas with binary sort qss.search can find any element in maximum 7 iterations making it most speedier. IF the number of extracted rows is say 100000 , then the proportion of summary to detail is 0.1 % . The use of arrays and qss functions will yield drastically improved results in such circumstances as compared to disk based groupings (in which all extracted records are written to disk) .
Though our documentation puts the array size limit to 5 MB , it works even beyond this limit . U can test it by declaring / allocating a string variable of 60 chars with an element size of say 500000 (28 MB odd) . It works .