Callbacks

Some FSVIEW calls do not directly return information to the calling program but make repeated calls back to a user-defined call. This is because fsviewc only processes items in blocks of ten.

For example, FSV-C-get-files-users uses the FSV-C-add-to-user-list callback to return a list of logged-on users for a specific file. Because fsviewc processes blocks of ten, repeated calls must be made in order to handle enough blocks of ten to code the total number of logged-on users being returned.

The following example shows an FSV-C-add-to-user-list callback. The entry point in this program allows fsviewc to execute the main body of the program. Without the entry point, the program would just set the number of users to 1 and exit:

 working-storage section.
*------------------------
 copy "fsviewop.cpy".
        
 01  work-vars.
     03  i                           pic xx comp-x.
     03  j                           pic xx comp-x.

 linkage section.

 copy 'fsdatab.cpy'.
 01  number-of-entries           pic xx comp-x.
       
 procedure division.
*------------------- 

     move 1 to user-list-ptr
     exit program
     .
 
 list-users section.

 entry FSV-C-add-to-user-list using number-of-entries
                                    fsvw-data-block.
 
     if hide-changeable
         perform user-test-masking
     end-if
 
     perform varying i from 1 by 1
             until i > 10
                or user-list-ptr > number-of-entries
         if FSVW-INSERT-LIST-BOX-ITEM (i) not = spaces
             if hide-changeable
                 move all "X"  
                   to FSVW-INSERT-LIST-BOX-ITEM (i)(s:l)
                 perform user-line-test-masking
             end-if
             display FSVW-INSERT-LIST-BOX-ITEM (i)(1:78)
         else
             if i = 1
                 display "No users found"
             end-if
             move 11 to i
         end-if
         add 1 to user-list-ptr
     end-perform
     .
 
     move zero to return-code
     exit program
     .