GUI ScreenIO for Windows

 ScreenIO.com


Using Listview Controls with file systems that lack Percentages

My File System Doesn't Support Percentages!

If you think about it, positioning using the scrollbar thumb is not particularly precise, especially in very large data files.  If you can make an educated guess about where that file position would be, it's possible to simulate percentages that are "good enough" to work.

One strategy might be, if you were browsing a file in alphabetical order, you could position at, say, the "M" records if listview-START-AT-PERCENT was 50%.  It would likely be close enough, provided you provided reasonable percentages for the records as you load them to the list.

Install the sample name-and-address application to see one way of using a listview with a COBOL ISAM file system, which doesn't provide percentages.  The file I/O subroutine simulates the percentages of records by rendering the keys to a numeric value and then using that value to compute an approximate percentage.  In a file with data that is uniformly distributed along the keypath, it works quite well.  Try it.

You may find that the sample application provides a good start for your own GUI ScreenIO application. 

Generic Percent Calculation method

We have a White Paper on how to obtain percents for almost any type of file.  File Percentages with ISAM.  This paper describes a method of calculating percentages on the fly which will work for most file types.  It is a more comprehensive description of the methodology used in the above mentioned Name and Address application.  It also supplies a sample FileIO subroutine in support of this method.

Accumulate-cache mode

Depending upon the size of your file, you may be able to simulate the desired behavior by specifying your listview is to operate in accumulate-cache mode when you design your panel.

When you specify this mode, your listview will only return listview-GET-NEXT events, which cause your file to be processed sequentially. 

If the user drags the scrollbar thumb to the 50% point, you will receive listview-GET-NEXTs until you pass a record that's loaded with 50%.  GUI ScreenIO will expand its cache as necessary to hold all of the records in your list so that it does not need to pass back GET-PRIOR or START-AT events. 

Preload-cache mode

If your list is of a reasonable size (whatever that is), you could specify preload-cache mode for the listview. 

When you specify this mode and you first load your listview, GUI ScreenIO will pass back listview-GET-NEXT events until it receives the last record in your list (the 100% record). 

Your percentages do not otherwise need to be accurate because GUI ScreenIO simply counts the records until you provide the last one.  This mode takes longer to load but is lightning-fast after that because the entire list in GUI ScreenIO's listview cache.

Accumulate- versus Preload-cache

If your file is large, and the user is most likely to use records near the beginning of the file, accumulate-cache mode can be very efficient because it only loads records on demand. 

Preload-cache mode is useful when the filesize is reasonable and it won't take too long to load the entire file to the listview.

Record Percentages

When you load data to the listview control, you must provide the percentage of the record in the list.  GUI ScreenIO uses this to compute how many records are in the file, and to position the scrollbar thumb when the list is displayed.

In addition, the percentage indicates to GUI ScreenIO which is the first record, and which is the last record in the list.  The first record must be 0 percent, and the last must be 100 percent.

The more accurate your percentages are, the more accurate the listview scrollbar will be. 


Related topics:


© 2000-2019 Norcom, all rights reserved 

TOC

Send feedback to Norcom