home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / rexxvim.zip / ADDRBOOK.CMD < prev    next >
OS/2 REXX Batch file  |  1994-07-13  |  13KB  |  251 lines

  1. /** AddrBook.cmd **/
  2. /**********************************************/
  3. /*                                            */
  4. /* Command line syntax:                       */
  5. /*                                            */
  6. /* AddrBook db_path user_password user_name   */
  7. /*                                            */
  8. /*                                            */
  9. /**********************************************/
  10. ARG db_path user_pw user_name
  11. '@echo off'
  12. '@cls'
  13. Say 'RexxVIM Address Book Demonstration Program'
  14. Say
  15.  
  16. /* Unload the function upon error */
  17. SIGNAL ON ERROR NAME done
  18.  
  19. /* Prompt for the parameters if not passed on the */
  20. /* command line                                   */
  21. if LENGTH(STRIP(db_path)) = 0 then do
  22.    Say 'Enter Postoffice Directory -'
  23.    PARSE PULL db_path .
  24.    Say
  25.    Say 'Enter User Name -'
  26.    PARSE PULL user_name
  27.    Say 'Enter Password -'
  28.    PARSE PULL user_pw
  29. end  /* Do */
  30.  
  31.  
  32. /* Load the RexxVIM extensions to Rexx */
  33. rc = RxFuncAdd('RxVIMLoadFuncs', 'REXXVIM', 'RxVIMLoadFuncs')
  34. if rc <> 0 then do
  35.    Say
  36.    Say 'RexxVIM failed to load, return code' rc
  37.    Say
  38.    Say 'Functions have been released.  Retry program.'
  39.    signal done
  40. end  /* Do */
  41. call RxVIMLoadFuncs
  42. Say 'Functions are now loaded'
  43. Say
  44.  
  45.  
  46. /* Initialize the VIM subsystem */
  47. rc = RxVIMInitialize()
  48. if (rc > 0) then call vimerr
  49.  
  50. /* Open a session with the postoffice using the parameters */
  51. /* provided by the user                                    */
  52. rc = RxVIMOpenSession(db_path,user_name,user_pw,Session)
  53. if (rc > 0) then call vimerr
  54.  
  55.  
  56.      /* Enumerate the addressbooks */
  57.      pos = ''                           /* Start at the beginning */
  58.      skipcnt = 1                        /* Move forward one at a time */
  59.      acount  = 1                        /* Retrieve 1 addressbook for each call */
  60.      more    = ''                       /* Set the value of more to nul */
  61.      action  = 'N'                      /* Set the value of repeat loop indicator to N */
  62.  
  63.      AttrDesc.0 = 2                               /* Retrieve 2 attributes for each addressbook */
  64.      AttrDesc.1.Selector = 'VIMSEL_NAME'          /* 1st attribute is the addressbook name */
  65.      AttrDesc.1.Buffer   = 'AddrName'             /* store results in this stem variable */
  66.      AttrDesc.2.Selector = 'VIMSEL_TOTAL_ENTRIES' /* 2nd attribute is total entries */
  67.      AttrDesc.2.Buffer   = 'AddrTotal'            /* store results in this stem variable */
  68.  
  69.      do until TRANSLATE(SUBSTR(action,1,1)) = 'X'
  70.  
  71.           /* Continue retrieving addressbook info until user enters N */
  72.  
  73.           rc = RxVIMEnumerateAddressBooks(Session,'pos',skipcnt,'AttrDesc','acount','more')
  74.           if (rc > 0) then call vimerr
  75.  
  76.           /* Display results */
  77.          'cls'
  78.           Say 'RexxVIM - (c) Innovative Business Technologies, Inc'
  79.           Say
  80.           Say 'Address Book Demo'
  81.           Say
  82.           Say '--------------------------------------------------------'
  83.           Say '    Address Book Name =' AddrName.1
  84.           Say '    Total Entries     =' AddrTotal.1
  85.           Say '--------------------------------------------------------'
  86.           Say
  87.           Say
  88.           Say 'Select an action for this message'
  89.           Say
  90.           Say '   N - Go to next Address Book'
  91.           Say '   D - Display each of the Address Book entries'
  92.           Say '   G - Get the current subtree name'
  93.           Say '   X - Exit demo now'
  94.           Say
  95.           Say 'Enter your selection below:'
  96.           PULL action
  97.  
  98.           /* Process the selection entered.  X will fall through the select statement */
  99.           select
  100.              when TRANSLATE(SUBSTR(action,1,1)) = 'N' then do
  101.                 /* Go to the next address book */
  102.                 /* Nothing to do.....loop will pull next address book */
  103.              end  /* Do */
  104.              when TRANSLATE(SUBSTR(action,1,1)) = 'G' then do
  105.  
  106.                 /* Open the current address book */
  107.                 rc = RxVIMOpenAddressBook(Session,AddrName.1,'AddrBkPtr')
  108.                 if (rc > 0) then call vimerr
  109.  
  110.                 /* Get the subtree of the address book */
  111.                 Subtree = ''
  112.                 SubRefNo = ''
  113.  
  114.                 rc = RxVIMGetCurrentSubtree(AddrBkPtr,'SubRefNo','Subtree')
  115.                 if (rc > 0) then call vimerr
  116.  
  117.                 /* Close the  address book */
  118.                 rc = RxVIMCloseAddressBook(AddrBkPtr)
  119.                 if (rc > 0) then call vimerr
  120.  
  121.                 Say '--------------------------------------------------------'
  122.                 Say '    Current Subtree  =' Subtree
  123.                 Say '--------------------------------------------------------'
  124.                 'pause'
  125.  
  126.              end  /* Do */
  127.              when TRANSLATE(SUBSTR(action,1,1)) = 'D' then do
  128.  
  129.                 /* Open the current address book */
  130.                 rc = RxVIMOpenAddressBook(Session,AddrName.1,'AddrBkPtr')
  131.                 if (rc > 0) then call vimerr
  132.  
  133.                 /* Enumerate the addressbook entries */                                                             
  134.                 epos = ''                           /* Start at the beginning */                                    
  135.                 eskipcnt = 1                        /* Move forward one at a time */                                
  136.                 eacount  = 1                        /* Retrieve 1 addressbook for each call */                      
  137.                 efilter  = 'VIMSEL_NO_FILTER'       /* no filtering */
  138.                 efdata   = ''                       /* no filter data */
  139.                 emore    = ''                       /* Set the value of more to nul */                              
  140.                 eaction  = 'N'                      /* Set the value of repeat loop indicator to N */               
  141.                                                                                                                     
  142.                 ItemDesc.0 = 3                               /* Retrieve 3 attributes for each entry */
  143.                 ItemDesc.1.Selector = 'VIMSEL_REF'           /* 1st attribute is the reference number */
  144.                 ItemDesc.1.Buffer   = 'ABE_Ref'              /* store results in this stem variable */
  145.                 ItemDesc.2.Selector = 'VIMSEL_NAME'          /* 2nd attribute is entry name */
  146.                 ItemDesc.2.Buffer   = 'ABE_Name'             /* store results in this stem variable */
  147.                 ItemDesc.3.Selector = 'VIMSEL_ADDRESS'       /* 3rd attribute is entry address */
  148.                 ItemDesc.3.Buffer   = 'ABE_Address'          /* store results in this stem variable */
  149.                                                                                                                     
  150.                 do until TRANSLATE(SUBSTR(eaction,1,1)) = 'X'                                                       
  151.                                                                                                                     
  152.                      /* Continue retrieving addressbook info until user enters X */                                 
  153.                                                                                                                     
  154.                      rc = RxVIMEnumerateAddressBookEntries(AddrBkPtr,'epos',eskipcnt,,
  155.                                            'ItemDesc','eacount',efilter,efdata,'emore')
  156.                      if (rc > 0) then call vimerr                                                                   
  157.                                                                                                                     
  158.                      /* Display results */                                                                          
  159.                     'cls'                                                                                           
  160.                      Say 'RexxVIM - (c) Innovative Business Technologies, Inc'                                      
  161.                      Say                                                                                            
  162.                      Say 'Address Book Demo with entry information'                                                 
  163.                      Say                                                                                            
  164.                      Say '--------------------------------------------------------'                                 
  165.                      Say '    Address Book Name =' AddrName.1                                                       
  166.                      Say '    Total Entries     =' AddrTotal.1                                                      
  167.                      Say '--------------------------------------------------------'                                 
  168.                      Say '    Name =   ' ABE_Name.1
  169.                      Say '    Address =' ABE_Address.1
  170.                      Say '    Ref No  =' ABE_Ref.1
  171.                      Say '--------------------------------------------------------'                                 
  172.                      Say                                                                                            
  173.                      Say                                                                                            
  174.                      Say 'Select an action for this message'                                                        
  175.                      Say                                                                                            
  176.                      Say '   N - Go to next Address Book entry'                                                     
  177.                      Say '   X - Exit to the main screen'                                                           
  178.                      Say                                                                                            
  179.                      Say 'Enter your selection below:'                                                              
  180.                      PULL eaction                                                                                   
  181.  
  182.                      select
  183.                         when TRANSLATE(SUBSTR(eaction,1,1)) = 'N' then do
  184.                            /* Go to the next address book entry */
  185.                            /* Nothing to do.....will loop to the next entry */
  186.                         end  /* Do */
  187.                      otherwise
  188.                      end  /* select */
  189.  
  190.                      /* End the loop if no more entries */
  191.                      if emore = 'False' then do
  192.                         Say 'All entries for this address book have been retrieved'
  193.                         eaction = 'X'
  194.                      end  /* Do */
  195.                                                                                                                     
  196.                 end /* Do */
  197.  
  198.                 /* Close the  address book */                                                            
  199.                 rc = RxVIMCloseAddressBook(AddrBkPtr)
  200.                 if (rc > 0) then call vimerr
  201.  
  202.              end  /* Do */
  203.           otherwise
  204.           end  /* select */
  205.  
  206.           if more = 'False' then do
  207.              Say 'All Address Books have been retrieved'
  208.              action = 'X'
  209.           end  /* Do */
  210.  
  211.      end /* do */
  212.  
  213. /* Close the session with the postoffice */
  214. rc = RxVIMCloseSession(Session)
  215. if (rc > 0) then call vimerr
  216.  
  217.  
  218. /* Terminate the active VIM subsystem connection */
  219. rc = RxVIMTerminate()
  220. if (rc > 0) then call vimerr
  221. signal done
  222.  
  223.  
  224. /***** VIMErr *******/
  225.  
  226. /* If an error occurs, this function will return the text */
  227. /* associated with the error.  Extended text may be       */
  228. /* displayed if it exists for the specified error.        */
  229.  
  230. VIMERR:
  231.  
  232. erc = RxVIMStatusText(Session,rc,'Status')
  233. Say
  234. Say '|-Error Information ------------------------------------|'
  235. Say '  Error Text -' status.1
  236. Say
  237. Say '  Ext Status -' status.2
  238. rc = RxVIMTerminate()
  239. signal done
  240.  
  241.  
  242. /* The done section will unload the RexxVIM extensions */
  243. /* and exit the program                                */
  244. DONE:
  245. /*** Drop all of the external functions ***/
  246. call RxVIMDropFuncs
  247. Say '|-------------------------------------------------------|'
  248. Say 'Demo Complete.  All functions released'
  249. 'pause'
  250. exit
  251.