      $set mfoo
      ************************************************************************
      * Copyright (C) 1994-1999 Micro Focus International Ltd.
      * All rights reserved.
      *  
      * This demonstration program is provided for use by users of 
      * Micro Focus products (the "Software") and may be used, 
      * modified and distributed as part of your application provided 
      * that you properly acknowledge the copyright of Micro Focus in this
      * material.
      *     
      * All conditions, warranties and undertakings, express or implied, 
      * statutory or otherwise, on the part of Micro Focus are excluded, 
      * including without limitation those of merchantability or fitness  
      * for purpose. This shall not, however, purport to exclude or 
      * restrict the liability of Micro Focus to any extent not 
      * permitted by law.
      *
      * IN NO EVENT WILL MICRO FOCUS BE LIABLE FOR ANY INDIRECT, 
      * INCIDENTAL, SPECIAL, CONSEQUENTIAL OR OTHER DAMAGES ARISING OUT 
      * OF THE USE OF THE DEMONSTRATION PROGRAM DISTRIBUTED WITH THE 
      * SOFTWARE, WHETHER OR NOT INFORMED OF THE POSSIBILITIES OF 
      * DAMAGES IN ADVANCE.  THESE LIMITATIONS APPLY TO ALL CAUSES OF 
      * ACTION, INCLUDING BREACH OF CONTRACT, BREACH OF WARRANTY, STRICT
      * LIABILITY, AND ANY ACTIONS IN TORTS.
      ************************************************************************
       class-control.
           Dictionary is class "dictinry"
           Association is class "associtn"
           CobolPicX is class "picx"
           Account is class "account"
           SavingsAccount is class "saccount"
           HighRateAccount is class "haccount"
           CheckAccount is class "caccount"
           EntryCallBack is class "entrycll"
           .

       working-storage section.
      *----A000. Data for initializing the collections
           01 wsCount              pic x(4) comp-5.
           01 wsSize               pic x(4) comp-5.
           01 wsCustomer           pic x(80).
           01 wsAmount             pic 9(10)v99.
           01 dispamount           pic 9(5).99.

           01 wsNull               object reference.
           01 picXnameLength       object reference.
           01 wsDictionary         object reference.
           01 wsAccount            object reference.
           01 wsDictionaryTemplate object reference.
           01 wsCallback           object reference.

      * A010. local-storage required to enable recursive callback.
       local-storage section.
       01 lsDummy                  pic x.
      * A020. Linkage required to pass data into callback.
       linkage section.
       01 lnkAccount               object reference.

       procedure division.
      *----A030. Create an Dictionary for holding key/value pairs.
      *----A040. Clone the COBOLPicX class to customer name length
           move length of wsCustomer to wsSize
           invoke CobolPicX "newClass" using wsSize
                                   returning picXnameLength
      *----A050. Clone a template from the Association class for the
      *          creating the dictionary.
           set wsNull to null
           invoke Association "newClass" using picXnameLength wsNull
                                     returning wsDictionaryTemplate
      *----A060. Create a dictionary
           move 10 to wsSize
           invoke Dictionary "ofValues" using wsDictionaryTemplate
                                              wsSize
                                    returning wsDictionary
      *----A070. Create an Account
           move spaces to wsCustomer
           move "Bob" to wsCustomer
           move 10 to wsAmount
           invoke CheckAccount "openAccount" using wsCustomer wsAmount
                                         returning wsAccount
      *----A080. Store in dictionary
           invoke wsDictionary "atPut" using wsCustomer wsAccount
      *----A090. Create two more accounts and store.
           move "Mike" to wsCustomer
           move 20 to wsAmount
           invoke SavingsAccount "openAccount" using wsCustomer wsAmount
                                           returning wsAccount
           invoke wsDictionary "atPut" using wsCustomer wsAccount
           move "Fred" to wsCustomer
           invoke CheckAccount "openAccount" using wsCustomer wsAmount
                                         returning wsAccount
           invoke wsDictionary "atPut" using wsCustomer wsAccount
      *----A100. Retrieve an account
           move spaces to wsCustomer
           move "Bob" to wsCustomer
           invoke wsDictionary "at" using wsCustomer returning wsAccount
      *----A110. Display the account details.
           invoke wsAccount "printStatement"
      *----A120. Set up iterator method.
           invoke EntryCallBack "new" using z"printAll"
                                  returning wsCallback
      *----A130. Iterate through the dictionary.
           invoke wsDictionary "do" using wsCallback
           stop run.

      * A150. Entry point for iteration. This entry point is called once
      *       for each value in the dictionary, and the value passed
      *       through in the lnkAccount parameter (declared in linkage
      *       at the top of this program.
       Entry "printAll" using lnkAccount.
      *----A160. Print statement for account referenced by lnkAccount.
           invoke lnkAccount "printStatement"
           exit program.

