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

  1. /** Msgacts.cmd **/
  2. /*********************************************/
  3. /*                                           */
  4. /* Command line syntax:                      */
  5. /*                                           */
  6. /* msgacts 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 Message Access 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.  
  51. /* Open a session with the postoffice using the parameters */
  52. /* provided by the user                                    */
  53. rc = RxVIMOpenSession(db_path,user_name,user_pw,Session)
  54. if (rc > 0) then call vimerr
  55.  
  56.  
  57. /* Open the default message container -- Inbox */
  58. rc = RxVIMOpenMessageContainer(Session,'','Inbox')
  59. if (rc > 0) then call vimerr
  60.  
  61.  
  62. /* Display all messages in Inbox if they exist */
  63.  
  64.      /* Enumerate messages in container -- Inbox */
  65.      pos = ''                           /* Start at the beginning of the container */
  66.      skipcnt = 1                        /* Move forward through the container one at a time */
  67.      mcount  = 1                        /* Retrieve 1 message for each call */
  68.      filter  = 'VIMSEL_NO_FILTER'       /* No filter, return all messages in inbox */
  69.      fdata   = ''                       /* No filter data */
  70.      flags   = 'VIM_NO_FLAGS'           /* No enumeration flags, return all messages in inbox */
  71.      more    = ''                       /* Set the value of more to nul */
  72.      action  = 'N'                      /* Set the value of repeat loop indicator to N */
  73.  
  74.      AttrDesc.0 = 3                               /* Retrieve 3 attributes for each message */
  75.      AttrDesc.1.Selector = 'VIMSEL_REF'           /* 1st attribute is the message reference number */
  76.      AttrDesc.1.Buffer   = 'MsgRefNo'             /* store results in this stem variable */
  77.      AttrDesc.2.Selector = 'VIMSEL_SUBJECT'       /* 2nd attribute is the message subject */
  78.      AttrDesc.2.Buffer   = 'Subject'              /* store results in this stem variable */
  79.      AttrDesc.3.Selector = 'VIMSEL_UNREAD_MAIL'   /* 3rd attribute is if unread */
  80.      AttrDesc.3.Buffer   = 'Unread'               /* store results in this stem variable */
  81.  
  82.      do until TRANSLATE(SUBSTR(action,1,1)) = 'X'
  83.  
  84.           /* Continue retrieving message info until user enters N */
  85.  
  86.           rc = RxVIMEnumerateMessages(Inbox,'pos',skipcnt,'AttrDesc','mcount',filter,fdata,flags,'more')
  87.           if (rc > 0) then call vimerr
  88.  
  89.           /* Display results */
  90.          'cls'
  91.           Say 'RexxVIM - (c) Innovative Business Technologies, Inc'
  92.           Say
  93.           Say 'Message Container Demo'
  94.           Say
  95.           Say '--------------------------------------------------------'
  96.           Say '    Message =' MsgRefNo.1
  97.           Say '    Subject =' Subject.1
  98.           Say '    Unread  =' Unread.1
  99.           Say '--------------------------------------------------------'
  100.           Say
  101.           Say 'Select an action for this message'
  102.           Say
  103.           Say '   D - Delete message'
  104.           Say '   F - File message in a folder'
  105.           Say '   N - Go to next message, leave this one in the Inbox'
  106.           Say '   M - Mark message as read'
  107.           Say '   H - Display message header info'
  108.           Say '   I - Display message items'
  109.           Say '   T - Display the first 60 characters of first message item'
  110.           Say '   X - Exit demo now'
  111.           Say
  112.           Say 'Enter your selection below:'
  113.           PULL action
  114.  
  115.           /* Process the selection entered.  X will fall through the select statement */
  116.           select
  117.              when TRANSLATE(SUBSTR(action,1,1)) = 'D' then do
  118.                 /* Delete message */
  119.                 rc = RxVIMRemoveMessage(Inbox,MsgRefNo.1)
  120.                 if (rc > 0) then call vimerr
  121.            end  /* Do */
  122.              when TRANSLATE(SUBSTR(action,1,1)) = 'F' then do
  123.                 /* File message in folder */
  124.                 Say 'Enter the name of the folder:'
  125.                 PULL category
  126.                  rc = RxVIMSetMessageCategory(Inbox,MsgRefNo.1,category)
  127.                 if (rc > 0) then call vimerr
  128.              end  /* Do */
  129.              when TRANSLATE(SUBSTR(action,1,1)) = 'N' then do
  130.                 /* Go to the next message */
  131.                 /* Nothing to do.....loop will pull next message */
  132.              end  /* Do */
  133.              when TRANSLATE(SUBSTR(action,1,1)) = 'M' then do
  134.                 /* Open message */
  135.                 rc = RxVIMOpenMessage(Inbox,MsgRefNo.1,'','MsgHandle')
  136.                 if (rc > 0) then call vimerr
  137.  
  138.                 /* Mark the message as read */
  139.                 rc = RxVIMMarkMessageAsRead(Inbox,MsgRefNo.1)
  140.                 if (rc > 0) then call vimerr
  141.  
  142.                 /* Close the message */
  143.                 rc = RxVIMCloseMessage(MsgHandle)
  144.                 if (rc > 0) then call vimerr
  145.              end  /* Do */
  146.              when TRANSLATE(SUBSTR(action,1,1)) = 'H' then do
  147.                 /* Open message */
  148.                 rc = RxVIMOpenMessage(Inbox,MsgRefNo.1,'','MsgHandle')
  149.                 if (rc > 0) then call vimerr
  150.  
  151.                 /* Get the message header info */
  152.                 attrDesc.0 = 2
  153.                 attrDesc.1.Selector = 'VIMSEL_FROM_NAME'
  154.                 attrDesc.1.Buffer   = 'from'
  155.                 attrDesc.2.Selector = 'VIMSEL_PRIORITY'
  156.                 attrDesc.2.Buffer   = 'priority'
  157.  
  158.                 rc = RxVIMGetMessageHeader(MsgHandle,'attrDesc')
  159.                 if (rc > 0) then call vimerr
  160.                 Say '--------------------------------------------------------'
  161.                 Say '    Message Sent by -' from
  162.                 Say '    Message Priority-' priority
  163.                 Say '--------------------------------------------------------'
  164.                 'pause'
  165.                 /* Close the message */
  166.                 rc = RxVIMCloseMessage(MsgHandle)
  167.                 if (rc > 0) then call vimerr
  168.              end  /* Do */
  169.              when TRANSLATE(SUBSTR(action,1,1)) = 'I' then do
  170.                 /* Open message */
  171.                 rc = RxVIMOpenMessage(Inbox,MsgRefNo.1,'','MsgHandle')
  172.                 if (rc > 0) then call vimerr
  173.  
  174.                 /* Retrieve all of the items for this message */
  175.                 ipos      = ''
  176.                 icount   = 20
  177.                 imore    = ''
  178.                 ItemDesc = ''
  179.                 ifilter   = 'VIMSEL_NO_FILTER'
  180.                 ifdata    = ''
  181.  
  182.                 rc = RxVIMEnumerateMessageItems(MsgHandle,'ipos',1,'icount','ItemDesc',,
  183.                                                 ifilter,ifdata,'imore')
  184.                 if (rc > 0) then call vimerr
  185.  
  186.                 'cls'
  187.                 Say 'RexxVIM - (c) Innovative Business Technologies, Inc'
  188.                 Say
  189.                 Say ' Message Information with Item Detail'
  190.                 Say '--------------------------------------------------------'
  191.                 Say '    Message =' MsgRefNo.1
  192.                 Say '    Subject =' Subject.1
  193.                 Say '    Unread  =' Unread.1
  194.                 Say '--------------------------------------------------------'
  195.  
  196.                 loopcnt = 1
  197.                 do while (loopcnt <= icount)
  198.                    /* Display each item descriptor entry */
  199.                    Say '    Item Class  -' ItemDesc.loopcnt.CLASS
  200.                    Say '    Item Type   -' ItemDesc.loopcnt.TYPE
  201.                    Say '    Item Name   -' ItemDesc.loopcnt.NAME
  202.                    Say '    Item Size   -' ItemDesc.loopcnt.SIZE
  203.                    Say '    Item Ref No -' ItemDesc.loopcnt.REF
  204.                    Say '--------------------------------------------------------'
  205.  
  206.                    loopcnt = loopcnt + 1
  207.                 end /* do */
  208.                 'pause'
  209.                 /* Close the message */
  210.                 rc = RxVIMCloseMessage(MsgHandle)
  211.                 if (rc > 0) then call vimerr
  212.              end  /* Do */
  213.              when TRANSLATE(SUBSTR(action,1,1)) = 'T' then do
  214.                 /* Open message */
  215.                 rc = RxVIMOpenMessage(Inbox,MsgRefNo.1,'','MsgHandle')
  216.                 if (rc > 0) then call vimerr
  217.  
  218.                 /* Retrieve all of the items for this message */
  219.                 ipos      = ''
  220.                 icount    = 20
  221.                 imore     = ''
  222.                 ItemDesc  = ''
  223.                 ifilter   = 'VIMSEL_CLASS'        /* Filter on item class */
  224.                 ifdata    = 'VIMSEL_NOTE_PART'    /* Retrieve only text items */
  225.  
  226.                 rc = RxVIMEnumerateMessageItems(MsgHandle,'ipos',1,'icount','ItemDesc',,
  227.                                                 ifilter,ifdata,'imore')
  228.                 if (rc > 0) then call vimerr
  229.                 /* Retrieve the text for the first message item */
  230.                 tconvert          = 'VIM_TEXT'         /* Use text conversion   */
  231.                 tflags            = ''                 /* No conversion flags   */
  232.                 BufDesc.Buffer    = 'ItemText'         /* Return buffer name    */
  233.                 BufDesc.Size      = 256                /* Size of return buffer */
  234.                 BufDesc.FileName  = ''
  235.  
  236.                 rc = RxVIMGetMessageItem(MsgHandle,ItemDesc.1.REF,tconvert,tflags,'BufDesc')
  237.                 if (rc > 0) then call vimerr
  238.  
  239.                 'cls'
  240.                 Say 'RexxVIM - (c) Innovative Business Technologies, Inc'
  241.                 Say
  242.                 Say ' Message Information with Item Detail'
  243.                 Say '--------------------------------------------------------'
  244.                 Say '    Message =' MsgRefNo.1
  245.                 Say '    Subject =' Subject.1
  246.                 Say '    Unread  =' Unread.1
  247.                 Say '--------------------------------------------------------'
  248.  
  249.                 /* Display each item descriptor entry */
  250.                 Say '    Item Class  -' ItemDesc.1.CLASS
  251.                 Say '    Item Type   -' ItemDesc.1.TYPE
  252.                 Say '    Item Name   -' ItemDesc.1.NAME
  253.                 Say '    Item Size   -' ItemDesc.1.SIZE
  254.                 Say '    Item Ref No -' ItemDesc.1.REF
  255.                 Say '--------------------------------------------------------'
  256.                 Say ' Message Contents for first item (max 60 characters) -'
  257.                 Say
  258.                 Say SUBSTR(ItemText,1,60)
  259.                 Say '--------------------------------------------------------'
  260.                 'pause'
  261.                 /* Close the message */
  262.                 rc = RxVIMCloseMessage(MsgHandle)
  263.                 if (rc > 0) then call vimerr
  264.              end  /* Do */
  265.           otherwise
  266.           end  /* select */
  267.  
  268.           /* End the loop if no more messages to retrieve */
  269.           if more = 'False' then do
  270.              Say 'All messages have been retrieved'
  271.              action = 'X'
  272.           end  /* Do */
  273.  
  274.      end /* do */
  275.  
  276.  
  277. /* Close the message container -- Inbox */
  278. rc = RxVIMCloseMessageContainer(Inbox)
  279. if (rc > 0) then call vimerr
  280.  
  281.  
  282. /* Close the session with the postoffice */
  283. rc = RxVIMCloseSession(Session)
  284. if (rc > 0) then call vimerr
  285.  
  286.  
  287. /* Terminate the active VIM subsystem connection */
  288. rc = RxVIMTerminate()
  289. if (rc > 0) then call vimerr
  290. signal done
  291.  
  292.  
  293. /***** VIMErr *******/
  294.  
  295. /* If an error occurs, this function will return the text */
  296. /* associated with the error.  Extended text may be       */
  297. /* displayed if it exists for the specified error.        */
  298.  
  299. VIMERR:
  300.  
  301. erc = RxVIMStatusText(Session,rc,'Status')
  302. Say
  303. Say '|-Error Information ------------------------------------|'
  304. Say '  Error Text -' status.1
  305. Say
  306. Say '  Ext Status -' status.2
  307. rc = RxVIMTerminate()
  308. signal done
  309.  
  310.  
  311. /* The done section will unload the RexxVIM extensions */
  312. /* and exit the program                                */
  313. DONE:
  314. /*** Drop all of the external functions ***/
  315. call RxVIMDropFuncs
  316. Say '|-------------------------------------------------------|'
  317. Say 'Demo Complete.  All functions released'
  318. 'pause'
  319. exit
  320.