× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Don't know if this is better or faster, but this is how I have done it for a few applications.

1. Load all the info to be displayed in the subfile into an array (multiple fields in an array described in a data structure), expanding the array as required using alloc and realloc. When I am finished filling the array, I do one more re-alloc to allocate memory equal to the number of records in the array.
2. Sort the array in memory in the default subfile sequence using qsort (this might not be necessary if you initially load the array in the default sequence).
3. Load the subfile from the array. Either the whole subfile or page at a time.
4. When user selects a different sequence, resort the array in memory using qsort and reload the subfile.


I know this may not work for a huge file, but with a limit of 9,999 records in a subfile (unless you use page at a time) and for my applications, this seems to work okay. I originally got the qsort sample from Jon's "Who Knew You Could Do that with RPGIV?" book.

I have thought about using the double click method of letting them sort the subfile, but I thought that not everyone would know to double click the columns. What I have done so far is to add a function key for "Sort Display" then give them a pop up window that allows them to select the sequence. The pop up window also gave me a change to try out the SNGCHCFLD (Single-Choice Selection Field) keyword on the display.

At 03:19 PM 3/29/2005, you wrote:
I write out the subfile to a work file in qtemp,
which has the same fields with one extra "KEY" field.  I load the sorted
columns data into both the matching field and the "KEY" field, then reload
the subfile from the indexed work file in QTEMP.    I am sure there are fast
and better ways,...

Dave Murvin DRM Enterprises, Inc.



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

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.