home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 18 REXX / 18-REXX.zip / rxvim.zip / NOTESRD.CMD < prev    next >
OS/2 REXX Batch file  |  1994-11-07  |  16KB  |  372 lines

  1. /** Notesrd.cmd **/
  2. /*********************************************/
  3. /*                                           */
  4. /* Command line syntax:                      */
  5. /*                                           */
  6. /* notesrd                                   */
  7. /*                                           */
  8. /*                                           */
  9. /*********************************************/
  10. '@echo off'
  11. '@cls'
  12. Say 'RexxVIM Message Read Demonstration Program'
  13. Say 'for Lotus Notes'
  14. Say
  15.  
  16. /* Unload the function upon error */
  17. SIGNAL ON ERROR NAME done
  18.  
  19.  
  20. /* Load the RexxVIM extensions to Rexx */
  21. rc = RxFuncAdd('RxVIMLoadFuncs', 'REXXVIM', 'RxVIMLoadFuncs')
  22. if rc <> 0 then do
  23.    Say
  24.    Say 'RexxVIM failed to load, return code' rc
  25.    Say
  26.    Say 'Functions have been released.  Retry program.'
  27.    signal done
  28. end  /* Do */
  29. call RxVIMLoadFuncs
  30. Say 'Functions are now loaded'
  31. Say
  32.  
  33.  
  34. /* Initialize the VIM subsystem */
  35. rc = RxVIMInitialize()
  36. if (rc > 0) then call vimerr
  37.  
  38.  
  39. /* Open a session with the postoffice using the parameters */
  40. /* provided by the user                                    */
  41. rc = RxVIMOpenSession('','','',Session)
  42. Say 'Opening the session'
  43. if (RxVIMStatus(rc) = 'VIMSTS_PASS_REQUIRED') then do
  44.    Say
  45.    Say 'Enter your password -'
  46.    parse pull user_pw .
  47.    rc = RxVIMOpenSession('','',user_pw,Session)
  48.    if (rc >0) then call vimerr
  49. end  /* Do */
  50.  
  51.  
  52. /* Open the default message container -- Inbox */
  53. rc = RxVIMOpenMessageContainer(Session,'','Inbox')
  54. Say 'Opening the message container'
  55. if (rc > 0) then call vimerr
  56.  
  57.  
  58. /* Display all messages in Inbox if they exist */
  59.  
  60.      /* Enumerate messages in container -- Inbox */
  61.      pos = ''                           /* Start at the beginning of the container */
  62.      skipcnt = 1                        /* Move forward through the container one at a time */
  63.      mcount  = 1                        /* Retrieve 1 message for each call */
  64.      filter  = 'VIMSEL_NO_FILTER'       /* No filter, return all messages in inbox */
  65.      fdata   = ''                       /* No filter data */
  66.      flags   = 'VIM_NO_FLAGS'           /* No enumeration flags, return all messages in inbox */
  67.      more    = ''                       /* Set the value of more to nul */
  68.      action  = 'N'                      /* Set the value of repeat loop indicator to N */
  69.  
  70.      AttrDesc.0 = 3                               /* Retrieve 3 attributes for each message */
  71.      AttrDesc.1.Selector = 'VIMSEL_REF'           /* 1st attribute is the message reference number */
  72.      AttrDesc.1.Buffer   = 'MsgRefNo'             /* store results in this stem variable */
  73.      AttrDesc.2.Selector = 'VIMSEL_SUBJECT'       /* 2nd attribute is the message subject */
  74.      AttrDesc.2.Buffer   = 'Subject'              /* store results in this stem variable */
  75.      AttrDesc.3.Selector = 'VIMSEL_UNREAD_MAIL'   /* 3rd attribute is if unread */
  76.      AttrDesc.3.Buffer   = 'Unread'               /* store results in this stem variable */
  77.  
  78.      do until TRANSLATE(SUBSTR(action,1,1)) = 'X'
  79.  
  80.           /* Continue retrieving message info until user enters N */
  81.  
  82.           rc = RxVIMEnumerateMessages(Inbox,'pos',skipcnt,'AttrDesc','mcount',filter,fdata,flags,'more')
  83.           Say 'Retrieving messages from in-box'
  84.           if (rc > 0) then call vimerr
  85.  
  86.           /* Display results */
  87.          'cls'
  88.           Say 'RexxVIM - (c) Innovative Business Technologies, Inc'
  89.           Say
  90.           Say 'Message Read Demo'
  91.           Say
  92.           Say '--------------------------------------------------------'
  93.           Say '    Message =' MsgRefNo.1
  94.           Say '    Subject =' Subject.1
  95.           Say '    Unread  =' Unread.1
  96.           Say '--------------------------------------------------------'
  97.           Say
  98.           Say 'Select an action for this message'
  99.           Say
  100.           Say '   N - Display the next message'
  101.           Say '   I - Display message items'
  102.           Say '   A - Display message recipients'
  103.           Say '   R - Read the first 60 characters of first message item'
  104.           Say '   E - Extract the message to the EXTRACT.tst file'
  105.           Say '   L - Display the message items for the extracted file'
  106.           Say '   X - Exit demo now'
  107.           Say
  108.           Say 'Enter your selection below:'
  109.           PULL action
  110.  
  111.           /* Process the selection entered.  X will fall through the select statement */
  112.           select
  113.              when TRANSLATE(SUBSTR(action,1,1)) = 'I' then do
  114.                 /* Open message */
  115.                 rc = RxVIMOpenMessage(Inbox,MsgRefNo.1,'','MsgHandle')
  116.                 if (rc > 0) then call vimerr
  117.  
  118.                 /* Retrieve all of the items for this message */
  119.                 ipos      = ''
  120.                 icount   = 2
  121.                 imore    = ''
  122.                 ItemDesc = ''
  123.                 ifilter   = 'VIMSEL_NO_FILTER'
  124.                 ifdata    = ''
  125.  
  126.                 rc = RxVIMEnumerateMessageItems(MsgHandle,'ipos',1,'icount','ItemDesc',,
  127.                                                 ifilter,ifdata,'imore')
  128.                 if (rc > 0) then call vimerr
  129.  
  130.                 'cls'
  131.                 Say 'RexxVIM - (c) Innovative Business Technologies, Inc'
  132.                 Say
  133.                 Say ' Message Information with Item Detail'
  134.                 Say '--------------------------------------------------------'
  135.                 Say '    Message =' MsgRefNo.1
  136.                 Say '    Subject =' Subject.1
  137.                 Say '    Unread  =' Unread.1
  138.                 Say '--------------------------------------------------------'
  139.  
  140.                 loopcnt = 1
  141.                 do while (loopcnt <= icount)
  142.                    /* Display each item descriptor entry */
  143.                    Say '    Item Class  -' ItemDesc.loopcnt.CLASS
  144.                    Say '    Item Type   -' ItemDesc.loopcnt.TYPE
  145.                    Say '    Item Name   -' ItemDesc.loopcnt.NAME
  146.                    Say '    Item Path   -' ItemDesc.loopcnt.PATH
  147.                    Say '    Item Size   -' ItemDesc.loopcnt.SIZE
  148.                    Say '    Item Ref No -' ItemDesc.loopcnt.REF
  149.                    Say '--------------------------------------------------------'
  150.  
  151.                    loopcnt = loopcnt + 1
  152.                 end /* do */
  153.                 'pause'
  154.                 /* Close the message */
  155.                 rc = RxVIMCloseMessage(MsgHandle)
  156.                 if (rc > 0) then call vimerr
  157.              end  /* Do */
  158.              when TRANSLATE(SUBSTR(action,1,1)) = 'R' then do
  159.                 /* Open message */
  160.                 rc = RxVIMOpenMessage(Inbox,MsgRefNo.1,'','MsgHandle')
  161.                 if (rc > 0) then call vimerr
  162.  
  163.                 /* Retrieve all of the items for this message */
  164.                 ipos      = ''
  165.                 icount    = 20
  166.                 imore     = ''
  167.                 ItemDesc  = ''
  168.                 ifilter   = 'VIMSEL_CLASS'        /* Filter on item class */
  169.                 ifdata    = 'VIMSEL_NOTE_PART'    /* Retrieve only text items */
  170.  
  171.                 rc = RxVIMEnumerateMessageItems(MsgHandle,'ipos',1,'icount','ItemDesc',,
  172.                                                 ifilter,ifdata,'imore')
  173.                 if (rc > 0) then call vimerr 
  174.                 /* Retrieve the text for the first message item */
  175.                 tconvert          = 'VIM_TEXT'         /* Use text conversion   */
  176.                 tflags            = ''                 /* No conversion flags   */
  177.  
  178.                 /* Open the first message item */
  179.                 rc = RxVIMOpenMessageItem(MsgHandle,ItemDesc.1.REF,tconvert,tflags,'ItemPtr')
  180.                 if (rc > 0) then call vimerr
  181.  
  182.                 /* Read the text from the open message */
  183.                 BufDesc.Buffer    = 'ItemText'         /* Return buffer name    */
  184.                 BufDesc.Size      = 60                 /* Size of return buffer */
  185.  
  186.                 rc = RxVIMReadMessageItem(ItemPtr,'BufDesc')
  187.  
  188.                 'cls'
  189.                 Say 'RexxVIM - (c) Innovative Business Technologies, Inc'
  190.                 Say
  191.                 Say ' Message Information with Item Detail'
  192.                 Say '--------------------------------------------------------'
  193.                 Say '    Message =' MsgRefNo.1
  194.                 Say '    Subject =' Subject.1
  195.                 Say '    Unread  =' Unread.1
  196.                 Say '--------------------------------------------------------'
  197.  
  198.                 /* Display each item descriptor entry */
  199.                 Say '    Item Class  -' ItemDesc.1.CLASS
  200.                 Say '    Item Type   -' ItemDesc.1.TYPE
  201.                 Say '    Item Name   -' ItemDesc.1.NAME
  202.                 Say '    Item Path   -' ItemDesc.1.PATH
  203.                 Say '    Item Size   -' ItemDesc.1.SIZE
  204.                 Say '    Item Ref No -' ItemDesc.1.REF
  205.                 Say '--------------------------------------------------------'
  206.                 Say ' Message Contents for first item (max 60 characters) -'
  207.                 Say
  208.                 Say SUBSTR(ItemText,1,60)
  209.                 Say '--------------------------------------------------------'
  210.                 'pause'
  211.  
  212.                 /* Close the message item */
  213.                 rc = RxVIMCloseMessageItem( ItemPtr )
  214.                 if (rc > 0) then call vimerr
  215.  
  216.                 /* Close the message */
  217.                 rc = RxVIMCloseMessage(MsgHandle)
  218.                 if (rc > 0) then call vimerr
  219.              end  /* Do */
  220.              when TRANSLATE(SUBSTR(action,1,1)) = 'A' then do
  221.                 /* Open message */
  222.                 rc = RxVIMOpenMessage(Inbox,MsgRefNo.1,'','MsgHandle')
  223.                 if (rc > 0) then call vimerr
  224.  
  225.                 /* Retrieve all of the items for this message */
  226.                 Receipt.0 = 1                               /* Retrieve 1 attributes for each recipient */
  227.                 Receipt.1.Selector = 'VIMSEL_NAME'          /* 1st attribute is the addressee */
  228.                 Receipt.1.Buffer   = 'SentTo'               /* store results in this stem variable */
  229.                 rtype   = 'VIMSEL_TO'
  230.                 rpos    = ''
  231.                 rcount  = 20
  232.                 rmore   = ''
  233.  
  234.                 rc = RxVIMEnumerateMessageRecipients(MsgHandle,rtype,'rpos',1,'Receipt','rcount','rmore')
  235.                 if (rc > 0) then call vimerr
  236.  
  237.                 'cls'
  238.                 Say 'RexxVIM - (c) Innovative Business Technologies, Inc'
  239.                 Say
  240.                 Say ' Message Information with Item Detail'
  241.                 Say '--------------------------------------------------------'
  242.                 Say '    Message =' MsgRefNo.1
  243.                 Say '    Subject =' Subject.1
  244.                 Say '    Unread  =' Unread.1
  245.                 Say '--------------------------------------------------------'
  246.  
  247.                 loopcnt = 1
  248.                 do while (loopcnt <= rcount)
  249.                    /* Display each item descriptor entry */
  250.                    Say '    Sent To  -' SentTo.loopcnt
  251.                    Say '--------------------------------------------------------'
  252.  
  253.                    loopcnt = loopcnt + 1
  254.                 end /* do */
  255.                 'pause'
  256.                 /* Close the message */
  257.                 rc = RxVIMCloseMessage(MsgHandle)
  258.                 if (rc > 0) then call vimerr
  259.              end  /* Do */
  260.              when TRANSLATE(SUBSTR(action,1,1)) = 'E' then do
  261.                 /* Open message */
  262.                 rc = RxVIMOpenMessage(Inbox,MsgRefNo.1,'','MsgHandle')
  263.                 if (rc > 0) then call vimerr
  264.  
  265.                 /* Extract the message to the file EXTRACT.tst */
  266.                 'erase extract.tst'
  267.                 rc = RxVIMExtractMessage(MsgHandle,'VIM_NO_FLAGS','extract.tst')
  268.                 if (rc > 0) then call vimerr
  269.  
  270.                 /* Close the message */
  271.                 rc = RxVIMCloseMessage(MsgHandle)
  272.                 if (rc > 0) then call vimerr
  273.              end  /* Do */
  274.              when TRANSLATE(SUBSTR(action,1,1)) = 'L' then do
  275.                 /* Open extracted message */
  276.                 rc = RxVIMOpenExtractedMessage(Session,'extract.tst','MsgHandle')
  277.                 if (rc > 0) then call vimerr
  278.  
  279.                 /* Retrieve all of the items for this message */
  280.                 ipos      = ''
  281.                 icount   = 20
  282.                 imore    = ''
  283.                 ItemDesc = ''
  284.                 ifilter   = 'VIMSEL_NO_FILTER'
  285.                 ifdata    = ''
  286.  
  287.                 rc = RxVIMEnumerateMessageItems(MsgHandle,'ipos',1,'icount','ItemDesc',,
  288.                                                 ifilter,ifdata,'imore')
  289.                 if (rc > 0) then call vimerr
  290.  
  291.                 'cls'
  292.                 Say 'RexxVIM - (c) Innovative Business Technologies, Inc'
  293.                 Say
  294.                 Say ' Message Information with Item Detail'
  295.                 Say '--------------------------------------------------------'
  296.                 Say '    Extracted Message = EXTRACT.tst'
  297.                 Say '--------------------------------------------------------'
  298.  
  299.                 loopcnt = 1
  300.                 do while (loopcnt <= icount)
  301.                    /* Display each item descriptor entry */
  302.                    Say '    Item Class  -' ItemDesc.loopcnt.CLASS
  303.                    Say '    Item Type   -' ItemDesc.loopcnt.TYPE
  304.                    Say '    Item Name   -' ItemDesc.loopcnt.NAME
  305.                    Say '    Item Path   -' ItemDesc.loopcnt.PATH
  306.                    Say '    Item Size   -' ItemDesc.loopcnt.SIZE
  307.                    Say '    Item Ref No -' ItemDesc.loopcnt.REF
  308.                    Say '--------------------------------------------------------'
  309.  
  310.                    loopcnt = loopcnt + 1
  311.                 end /* do */
  312.                 'pause'
  313.                 /* Close the message */
  314.                 rc = RxVIMCloseMessage(MsgHandle)
  315.                 if (rc > 0) then call vimerr
  316.              end  /* Do */
  317.           otherwise
  318.           end  /* select */
  319.  
  320.           /* End the loop if no more messages to retrieve */
  321.           if more = 'False' then do
  322.              Say 'All messages have been retrieved'
  323.              action = 'X'
  324.           end  /* Do */
  325.  
  326.      end /* do */
  327.  
  328.  
  329. /* Close the message container -- Inbox */
  330. rc = RxVIMCloseMessageContainer(Inbox)
  331. if (rc > 0) then call vimerr
  332.  
  333.  
  334. /* Close the session with the postoffice */
  335. rc = RxVIMCloseSession(Session)
  336. if (rc > 0) then call vimerr
  337.  
  338.  
  339. /* Terminate the active VIM subsystem connection */
  340. rc = RxVIMTerminate()
  341. if (rc > 0) then call vimerr
  342. signal done
  343.  
  344.  
  345. /***** VIMErr *******/
  346.  
  347. /* If an error occurs, this function will return the text */
  348. /* associated with the error.  Extended text may be       */
  349. /* displayed if it exists for the specified error.        */
  350.  
  351. VIMERR:
  352.  
  353. erc = RxVIMStatusText(Session,rc,'Status')
  354. Say
  355. Say '|-Error Information ------------------------------------|'
  356. Say '  Error Text -' status.1
  357. Say
  358. Say '  Ext Status -' status.2
  359. rc = RxVIMTerminate()
  360. signal done
  361.  
  362.  
  363. /* The done section will unload the RexxVIM extensions */
  364. /* and exit the program                                */
  365. DONE:
  366. /*** Drop all of the external functions ***/
  367. call RxVIMDropFuncs
  368. Say '|-------------------------------------------------------|'
  369. Say 'Demo Complete.  All functions released'
  370. 'pause'
  371. exit
  372.