|
On Wed, 14 Apr 2004 CarollaT@xxxxxxxxxxxxxx wrote: [SNIP] > First of all, can I somehow DIM the data structure array based on the number > of records in the company file? This way, if we add companies, I won't have > to modify and re-compile. Also, I won't have to make a guess-timate of > around 150, and dimension unneeded elements. [SNIP] With only 150 elements, I wouldn't worry much about it. In fact, I'd go with 300 elements just to be safe. If for some reason you're really worried about this, you can define the array as 30000 elements, but base it on a pointer so that no memory is reserved. Allocate the memory as you need it (with the %alloc() and %realloc BIFs)... this won't perform as well as simply declaring a 300 element array, but will be a bit more efficient on memory. If you do use the dynamic allocation method, make sure that you never try to access the un-allocated memory, and don't run it through an op-code like SORTA (which will also try to access that memory.) > Then, if the array elements contain a 3-alpha and a 11,2-packed field, can I > use the %Lookup BIF to lookup the 3-alpha identifier for each company as I > am summarizing? Will the other data structure field interfere with this? I don't think you can use %lookup() on an array of data structures or a MODS. You may be able to use it with those overlaid array thinggies, though. Again, if the array is dynamic, make sure you specify a number of elements to %lookup() so that it does not access areas that you haven't allocated. Are you intending to sort the array? If so, you can use qsort() to do the sort, and bsearch() to search through it -- this will be very fast, and will work with data structures. If the array is not dynamic, SORTA can be used to sort it, but it's slower than qsort(). You can still use bsearch() though. Another idea would be user indexes... though, I don't know that I'd go through all the trouble for a mere 64-150 elements.
As an Amazon Associate we earn from qualifying purchases.
This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.