home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 16 / CD_ASCQ_16_0994.iso / news / 4611 / fw16d.ins / SAMPLES / EMAIL.PRG < prev    next >
Text File  |  1994-04-30  |  45KB  |  1,084 lines

  1. /*
  2. ┌─────────────────────────────────────────────────────────────────────────────┐
  3. │                                                                             │
  4. │ Program    : EMail                                                          │▒
  5. │ Author     : Jon Kilburn                                                    │▒
  6. │ Date       : March 20, 1994                                                 │▒
  7. │ Notes      : This is a demo of how to create a working windows application  │▒
  8. │              In FiveWin.  This is _NOT_ meant to be a classy EMail system   │▒
  9. │              in fact it is to be a viewed as an example of how easy         │▒
  10. │              FiveWin is to learn.  Make any modification to the program     │▒
  11. │              that you wish.  It uses both DIALOGs created on the fly and    │▒
  12. │              DIALOGs extracted from inside the EMAIL.DLL                    │▒
  13. │                                                                             │▒
  14. │              This program is release to the Public Domain                   │▒
  15. │                                                                             │▒
  16. │ Libraries  : FiveWin                                                        │▒
  17. │              WinApi                                                         │▒
  18. │                                                                             │▒
  19. └─────────────────────────────────────────────────────────────────────────────┘▒
  20.  ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  21. */
  22.  
  23. #include "COMMON.CH"
  24. #include "FIVEWIN.CH"
  25.  
  26. #define  CRLF chr(13) + chr(10)
  27.  
  28. /*
  29. ┌──────────────────────────────── N O T I C E ────────────────────────────────┐
  30. │                                                                             │
  31. │ The following are defines to associate to windows dialog item IDs.  This    │▒
  32. │ is a standard practice for use with a dialog script.  The reason that this  │▒
  33. │ is done is so that the code can be more easily read.  Since many dialogs    │▒
  34. │ will often be created with the same numbers these Unique IDs make your      │▒
  35. │ code more readable and allow easy assocation between the dialogs and there  │▒
  36. │ controls.  For this example I just used the PreFix ID_ (since this is a     │▒
  37. │ small app). For larger apps with many dialogs you should use a descriptive  │▒
  38. │ prefix such as (in the case of the add mail dialog) ADD_ etc.               │▒
  39. │                                                                             │▒
  40. └─────────────────────────────────────────────────────────────────────────────┘▒
  41.   ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  42. */
  43.  
  44. //─────────────────────────── Defines for Add Mail
  45. #define  ID_DATE     1000
  46. #define  ID_SUBJECT  1001
  47. #define  ID_GDATE    8000
  48. #define  ID_GSUBJECT 8001
  49. #define  ID_GMEMO    8002
  50. #define  ID_SENDB    9000
  51. #define  ID_CANCELB  9001
  52.  
  53. //────────────────────────── Defines for Listbox (Select User)
  54. #define  ID_LISTBOX  8000
  55. #define  ID_OKBUT    9000
  56. #define  ID_CANCBUT  9001
  57.  
  58. //────────────────────────── Defines for Read Mail
  59. #define ID_NEXT      9000
  60. #define ID_PREV      9001
  61. #define ID_DELETE    9002
  62. #define ID_CANCELR   9003
  63.  
  64.  
  65. STATIC oWnd
  66.  
  67. FUNCTION Brain()
  68. /*
  69. ┌─────────────────────────────────────────────────────────────────────────────┐
  70. │                                                                             │
  71. │ Function   : Brain()--> NIL                                                 │▒
  72. │ Programmer : Jon Kilburn                                                    │▒
  73. │ Date       : March 20, 1994                                                 │▒
  74. │ Modified   :                                                                │▒
  75. │ Purpose    : Main procedure...                                              │▒
  76. │ Parameters : None                                                           │▒
  77. │ Returns    : NIL                                                            │▒
  78. │ Libraries  : FiveWin                                                        │▒
  79. │ DataBases  : None                                                           │▒
  80. │                                                                             │▒
  81. └─────────────────────────────────────────────────────────────────────────────┘▒
  82.   ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  83. */
  84. LOCAL           ;
  85.       oBar,     ;
  86.       oBrush,   ;
  87.       oIcon
  88.  
  89.    OpenFiles(.T.)
  90.  
  91.    SET 3DLOOK ON
  92.    IF LogOn()
  93.  
  94.       DEFINE BRUSH oBrush STYLE BRICKS
  95.       DEFINE ICON  oIcon  FILE "MAIL.ICO"
  96.  
  97.       DEFINE WINDOW oWnd FROM 1, 5 TO 20, 65   ;
  98.              BRUSH oBrush                      ;
  99.              TITLE "E-Mail System version 1.0" ;
  100.              ICON  oIcon                       ;
  101.              MENU  BuildMenu()
  102.  
  103.       DEFINE BUTTONBAR oBar OF oWnd
  104.  
  105.       DEFINE BUTTON FILE "Exit.bmp" OF oBar MESSAGE "Exit E-Mail System" ;
  106.       ACTION IF(MsgYesNo("Do you wish to exit E-Mail?", "Exit"),oWnd:end(),)
  107.  
  108.       DEFINE BUTTON FILE "File.bmp" OF oBar MESSAGE  "Read E-Mail" ;
  109.       ACTION ReadMail()
  110.  
  111.       DEFINE BUTTON FILE "Edit.bmp" OF oBar MESSAGE  "Add New E-Mail Message" ;
  112.       ACTION AddMail()
  113.  
  114.       DEFINE BUTTON FILE "Link.bmp" OF oBar MESSAGE "Remove Deleted Records" ;
  115.       ACTION PackFile()
  116.  
  117.       DEFINE BUTTON FILE "Printer.bmp" OF oBar MESSAGE "Printer Setup" ;
  118.       ACTION TPrinter():New("Test")
  119.  
  120.       DEFINE BUTTON FILE "Help.bmp" OF oBar MESSAGE "Help on E-Mail" ;
  121.       ACTION winhelp("winhelp.hlp")
  122.  
  123.       SET MESSAGE OF oWnd TO ""
  124.       ACTIVATE WINDOW oWnd MAXIMIZED
  125.    ENDIF
  126.  
  127.    OpenFiles(.F.)
  128.    SET 3DLOOK OFF
  129.  
  130. RETURN nil
  131.  
  132.  
  133.  
  134. STATIC FUNCTION OpenFiles(open)
  135. /*
  136. ┌─────────────────────────────────────────────────────────────────────────────┐
  137. │                                                                             │
  138. │ Function   : OpenFiles( [open] )--> NIL                                     │▒
  139. │ Programmer : Jon Kilburn                                                    │▒
  140. │ Date       : March 20, 1994                                                 │▒
  141. │ Modified   :                                                                │▒
  142. │ Purpose    : Open all the database and index files associated to the EMAIL  │▒
  143. │              System.  If any of the files don't exist create them (this     │▒
  144. │              includes both database and index files)                        │▒
  145. │ Parameters : open -- Logical open/close files flag                          │▒
  146. │ Returns    : NIL                                                            │▒
  147. │ Libraries  : FiveWin                                                        │▒
  148. │ DataBases  : USER -- Database of all Email Users                            │▒
  149. │              MAIL -- Database of all Email Messages                         │▒
  150. │                                                                             │▒
  151. └─────────────────────────────────────────────────────────────────────────────┘▒
  152.   ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  153. */
  154. LOCAL           ;
  155.      aStru
  156.  
  157.    IF open
  158.       IF ! file("USER.DBF")
  159.          aStru := {                           ;
  160.                     {"Name",     "C", 20, 0}, ;
  161.                     {"User",     "C",  3, 0}, ;
  162.                     {"Title",    "C", 20, 0}  ;
  163.                   }
  164.          dbcreate("USER", aStru)
  165.          USE USER NEW EXCLUSIVE
  166.          IF ! neterr()
  167.             INDEX ON FIELD->Name TO USER
  168.          ELSE
  169.             MsgInfo("Unable to Create User File Index!","Fatal Error")
  170.             CLOSE ALL
  171.             QUIT
  172.          ENDIF
  173.          CLOSE ALL
  174.  
  175.          SELECT 1
  176.          USE USER INDEX USER SHARED NEW
  177.       ELSE
  178.          IF ! file("USER.NTX")
  179.             USE USER EXCLUSIVE
  180.             IF ! neterr()
  181.                INDEX ON FIELD->Name TO USER
  182.                CLOSE ALL
  183.                SELECT 1
  184.                USE USER INDEX USER SHARED NEW
  185.             ELSE
  186.                MsgInfo("Unable to Create User File Index!","Fatal Error")
  187.                CLOSE ALL
  188.                QUIT
  189.             ENDIF
  190.          ENDIF
  191.  
  192.          SELECT 1
  193.          USE USER INDEX USER SHARED NEW
  194.       ENDIF
  195.  
  196.       IF ! file("MAIL.DBF")
  197.          aStru := {                          ;
  198.                     {"User",    "C",  3, 0}, ;
  199.                     {"Mail",    "M", 10, 0}, ;
  200.                     {"Subject", "C", 20, 0}, ;
  201.                     {"Date",    "D",  8, 0}, ;
  202.                     {"Read",    "L",  1, 0}  ;
  203.                   }
  204.          dbcreate("MAIL", aStru)
  205.          SELECT 2
  206.          USE MAIL NEW EXCLUSIVE
  207.          IF ! neterr()
  208.             INDEX ON MAIL->User TO MAIL
  209.          ELSE
  210.             MsgInfo("Unable to Create Mail File Index!","Fatal Error")
  211.             CLOSE ALL
  212.             QUIT
  213.          ENDIF
  214.          MAIL->(dbclosearea())
  215.  
  216.          SELECT 2
  217.          USE MAIL INDEX MAIL SHARED NEW
  218.       ELSE
  219.          IF ! file("MAIL.NT")
  220.             SELECT 2
  221.             USE MAIL EXCLUSIVE NEW
  222.             IF ! neterr()
  223.                INDEX ON MAIL->User TO MAIL
  224.             ELSE
  225.                MsgInfo("Unable to Create Mail File Index!","Fatal Error")
  226.                CLOSE ALL
  227.                QUIT
  228.             ENDIF
  229.             MAIL->(dbclosearea())
  230.          ENDIF
  231.  
  232.          SELECT 2
  233.          USE MAIL INDEX MAIL SHARED NEW
  234.       ENDIF
  235.    ELSE
  236.        CLOSE ALL
  237.    ENDIF
  238.  
  239. RETURN nil
  240.  
  241.  
  242. STATIC FUNCTION LogOn()
  243. /*
  244. ┌─────────────────────────────────────────────────────────────────────────────┐
  245. │                                                                             │
  246. │ Function   : LogOn()--> success                                             │▒
  247. │ Programmer : Jon Kilburn                                                    │▒
  248. │ Date       : March 20, 1994                                                 │▒
  249. │ Modified   :                                                                │▒
  250. │ Purpose    : Get the current user so they can read there mail               │▒
  251. │ Parameters : None                                                           │▒
  252. │ Returns    : NIL                                                            │▒
  253. │ Libraries  : FiveWin                                                        │▒
  254. │ DataBases  : USER                                                           │▒
  255. │                                                                             │▒
  256. └─────────────────────────────────────────────────────────────────────────────┘▒
  257.   ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  258. */
  259. LOCAL           ;
  260.       lReturn,  ;
  261.       oDlg,     ;
  262.       cName
  263.  
  264.    lReturn := .T.
  265.    cName   := space(22)
  266.  
  267.    IF ! USER->(lastrec()) < 1
  268.       DEFINE DIALOG oDlg FROM 5,5 TO 11, 29 TITLE "User Logon"
  269.  
  270.       @ 0.2, 1 SAY "User Name.." OF oDlg
  271.       @ 1.2, 1 GET cName OF oDlg PICTURE "@!"
  272.  
  273.       //─────────────────────── Define the Action Associated to the OK Button
  274.       @ 2.7, 1 BUTTON "&Ok"  OF oDlg SIZE 40,12                              ;
  275.       ACTION  (USER->(dbseek(trim(cName))),                                  ;
  276.            IF(! USER->(found()), MsgInfo("Name Not Found!", "Error"),),          ;
  277.            oDlg:end())
  278.  
  279.       //──────────────────- Define the Action Associated to the Cancel Button
  280.       @ 2.7, 7 BUTTON "&Cancel" OF oDlg SIZE 40, 12 ACTION oDlg:end()
  281.  
  282.       ACTIVATE DIALOG oDlg CENTERED
  283.       IF ! USER->(found())
  284.          lReturn := .F.
  285.       ELSE
  286.          SetRead(.T.)
  287.          IF MAIL->(dbseek(USER->User))
  288.             MsgInfo("You have Mail waiting", "Mail Found")
  289.          ENDIF
  290.       ENDIF
  291.    ENDIF
  292.  
  293. RETURN lReturn
  294.  
  295.  
  296.  
  297. STATIC FUNCTION SetRead(set)
  298. /*
  299. ┌─────────────────────────────────────────────────────────────────────────────┐
  300. │                                                                             │
  301. │ Function   : SetRead( set )--> cUser                                        │▒
  302. │ Programmer : Jon Kilburn                                                    │▒
  303. │ Date       : March 20, 1994                                                 │▒
  304. │ Modified   :                                                                │▒
  305. │ Purpose    : Store the user initials to seek into the MAIL file             │▒
  306. │ Parameters : set -- Logical set the user flag                               │▒
  307. │ Returns    : NIL                                                            │▒
  308. │ Libraries  : FiveWin                                                        │▒
  309. │ DataBases  : USER                                                           │▒
  310. │                                                                             │▒
  311. └─────────────────────────────────────────────────────────────────────────────┘▒
  312.   ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  313. */
  314. STATIC          ;
  315.       cUser
  316.  
  317.     DEFAULT set TO FALSE
  318.  
  319.     IF set
  320.        cUser := USER->User
  321.     ENDIF
  322.  
  323. RETURN cUser
  324.  
  325.  
  326.  
  327. STATIC FUNCTION BuildMenu()
  328. /*
  329. ┌─────────────────────────────────────────────────────────────────────────────┐
  330. │                                                                             │
  331. │ Function   : BuildMenu()--> oMenu                                           │▒
  332. │ Programmer : Jon Kilburn                                                    │▒
  333. │ Date       : March 20, 1994                                                 │▒
  334. │ Modified   :                                                                │▒
  335. │ Purpose    : Creates the menu object [ oMenu ] and returns it.              │▒
  336. │ Parameters : None                                                           │▒
  337. │ Returns    : NIL                                                            │▒
  338. │ Libraries  : FiveWin                                                        │▒
  339. │ DataBases  : None                                                           │▒
  340. │                                                                             │▒
  341. └─────────────────────────────────────────────────────────────────────────────┘▒
  342.   ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  343. */
  344. LOCAL           ;
  345.      oMenu
  346.  
  347.    //──────────────────────────────────────────────── Define the Menu Object
  348.    MENU oMenu
  349.  
  350.       //─────────────────────────- Create a File Option and Sub menu Options
  351.       MENUITEM "&File"
  352.       MENU
  353.          MENUITEM "&Read Mail" MESSAGE "Read E-Mail" ;
  354.          ACTION ReadMail()
  355.  
  356.          MENUITEM "&Add Mail" MESSAGE "Add New E-Mail Message" ;
  357.          ACTION AddMail()
  358.  
  359.          MENUITEM "&Pack File" MESSAGE "Remove Deleted Records" ;
  360.          ACTION PackFile()
  361.  
  362.          SEPARATOR
  363.  
  364.          MENUITEM "&Exit" MESSAGE "Exit E-Mail System" ;
  365.          ACTION IF(MsgYesNo("Do you wish to exit E-Mail?", "Exit"),oWnd:end(),)
  366.       ENDMENU
  367.  
  368.       //──────────────────────────────────────── Creates A Users Menu Option
  369.       MENUITEM "&Users"
  370.       MENU
  371.          MENUITEM "&Add" MESSAGE "Add a New E-Mail User" ;
  372.          ACTION AddUser()
  373.  
  374.          MENUITEM "&Modify" MESSAGE "Modify An Existing E-Mail User";
  375.          ACTION USER->(Browse("User Database", "", { || AddUser(.T.) },   ;
  376.                              { || DelUser() }, { || FindUser() }))
  377.  
  378.       ENDMENU
  379.  
  380.       //────────────────────────────────────────────────── Print Menu Options
  381.       MENUITEM "&Print"
  382.       MENU
  383.          MENUITEM "&Print All" MESSAGE "Print all E-Mail" ;
  384.          ACTION MsgInfo("Print All", "")
  385.  
  386.          MENUITEM "Print &Range" MESSAGE "Print E-Mail for a Date Range" ;
  387.          ACTION MsgInfo("Print Range", "")
  388.  
  389.          //────────────────────────── Access the Printer Control Dialog
  390.          MENUITEM "&Setup..." MESSAGE "Printer Setup" ;
  391.          ACTION TPrinter():New("Test")
  392.       ENDMENU
  393.  
  394.       //────────────────────────── Create a Help Option and Sub menu Options
  395.       MENUITEM "&Help"
  396.       MENU
  397.          MENUITEM "&How To Use Help" ;
  398.          MESSAGE "How To Use Windows Help" ACTION winhelp("winhelp.hlp")
  399.  
  400.          SEPARATOR
  401.  
  402.          MENUITEM "&About E-Mail..." ;
  403.          MESSAGE "About the FiveWin E-Mail System"         ;
  404.          ACTION MsgInfo("FiveWin E-Mail System" + CRLF +  ;
  405.                     "Written By Jon Kilburn" + CRLF +      ;
  406.                     "Version 1.0", "About")
  407.      ENDMENU
  408.  
  409.    ENDMENU
  410.  
  411. RETURN oMenu
  412.  
  413.  
  414.  
  415. STATIC FUNCTION AddUser(modify)
  416. /*
  417. ┌─────────────────────────────────────────────────────────────────────────────┐
  418. │                                                                             │
  419. │ Function   : AddUser( [modify] )--> NIL                                     │▒
  420. │ Programmer : Jon Kilburn                                                    │▒
  421. │ Date       : March 20, 1994                                                 │▒
  422. │ Modified   :                                                                │▒
  423. │ Purpose    : Add or Modify a User to the USERS database                     │▒
  424. │ Parameters : modify -- Logical flag for Modify/Add Mode                     │▒
  425. │ Returns    : NIL                                                            │▒
  426. │ Libraries  : FiveWin                                                        │▒
  427. │ DataBases  : USER                                                           │▒
  428. │                                                                             │▒
  429. └─────────────────────────────────────────────────────────────────────────────┘▒
  430.   ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  431. */
  432. LOCAL           ;
  433.      oDlg,      ;
  434.      cName,     ;
  435.      oName,     ;
  436.      cUser,     ;
  437.      oUser,     ;
  438.      cTitle,    ;
  439.      oTitle,    ;
  440.      cStatus
  441.  
  442.    DEFAULT modify TO FALSE
  443.  
  444.    IF ! modify
  445.       cName  := space(20)
  446.       cUser  := space(3)
  447.       cTitle := space(20)
  448.    ELSE
  449.       cName  := USER->Name
  450.       cUser  := USER->User
  451.       cTitle := USER->Title
  452.    ENDIF
  453.  
  454.    DEFINE DIALOG oDlg FROM 5,5 TO 13, 55 TITLE "Add New User"
  455.  
  456.    @ 1, 1 SAY "&Name" OF oDlg
  457.    @ 1, 8 GET oName VAR cName OF oDlg PICTURE "@!"
  458.  
  459.    @ 2, 1 SAY "&User Id" OF oDlg
  460.    @ 2, 8 GET oUser VAR cUser OF oDlg PICTURE "!!!" SIZE 20,11
  461.  
  462.    @ 3, 1 SAY "&Title" OF oDlg
  463.    @ 3, 8 GET oTitle VAR cTitle OF oDlg PICTURE "@!"
  464.  
  465.    @ 1, 21.2 BUTTON "&Ok" OF oDlg SIZE 40, 12   ;
  466.    ACTION ( oName:refresh(),  ;
  467.             oUser:refresh(),  ;
  468.             oTitle:refresh(), ;
  469.             UpdateUser(cName, cUser, cTitle, modify, oDlg) )
  470.  
  471.    @ 2.3, 21.2 BUTTON "&Cancel" OF oDlg SIZE 40, 12 ;
  472.    ACTION oDlg:end()
  473.  
  474.    ACTIVATE DIALOG oDlg CENTERED WAIT
  475.  
  476. RETURN nil
  477.  
  478.  
  479. STATIC FUNCTION UpdateUser(cName, cUser, cTitle, modify, oDlg)
  480. /*
  481. ┌─────────────────────────────────────────────────────────────────────────────┐
  482. │                                                                             │
  483. │ Function   : UpdateUser( cName, cUser, cTitle, modify, oDlg )--> NIL        │▒
  484. │ Programmer : Jon Kilburn                                                    │▒
  485. │ Date       :                                                                │▒
  486. │ Modified   :                                                                │▒
  487. │ Purpose    : Save the current Dialog Contents to the USER file              │▒
  488. │ Parameters : cName  -- Name of the User                                     │▒
  489. │              cUser  -- User Initials                                        │▒
  490. │              cTitle -- Title of the User                                    │▒
  491. │              modify -- Logical modify flag (Determines if APPEND is called) │▒
  492. │              oDlg   -- Dialog Object                                        │▒
  493. │ Returns    : NIL                                                            │▒
  494. │ Libraries  : FiveWin                                                        │▒
  495. │ DataBases  : USER                                                           │▒
  496. │                                                                             │▒
  497. └─────────────────────────────────────────────────────────────────────────────┘▒
  498.   ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  499. */
  500.  
  501.    DEFAULT modify TO FALSE
  502.  
  503.    IF ! modify
  504.       USER->(dbgobottom())
  505.       USER->(dbappend())
  506.       IF USER->(rlock())
  507.          USER->Name     := cName
  508.          USER->User     := cUser
  509.          USER->Title    := cTitle
  510.          USER->(dbunlock())
  511.       ELSE
  512.          MsgInfo("Unable to update User File!", "Add Error")
  513.       ENDIF
  514.    ELSE
  515.       IF USER->(rlock())
  516.          USER->Name     := cName
  517.          USER->User     := cUser
  518.          USER->Title    := cTitle
  519.          USER->(dbunlock())
  520.       ELSE
  521.          MsgInfo("Unable to update User File!", "Modify Error")
  522.       ENDIF
  523.    ENDIF
  524.  
  525.    oDlg:end()
  526.  
  527. RETURN nil
  528.  
  529.  
  530. STATIC FUNCTION Browse(cTitle, cListName, bModify, bDelete, bSearch)
  531. /*
  532. ┌─────────────────────────────────────────────────────────────────────────────┐
  533. │                                                                             │
  534. │ Function   : Browse( cTitle, cListName, bModify, bDelete, bSearch )--> NIL  │▒
  535. │ Programmer : Jon Kilburn                                                    │▒
  536. │ Date       :                                                                │▒
  537. │ Modified   :                                                                │▒
  538. │ Purpose    : Browse the USER database                                       │▒
  539. │ Parameters : cTitle    -- Title of the Browse window                        │▒
  540. │              cListName -- Title of the Listbox                              │▒
  541. │              bModify   -- Modify Code Block                                 │▒
  542. │              bDelete   -- Delete Code Block                                 │▒
  543. │              bSearch   -- Search Code Block                                 │▒
  544. │ Returns    : NIL                                                            │▒
  545. │ Libraries  : FiveWin                                                        │▒
  546. │ DataBases  : USER                                                           │▒
  547. │                                                                             │▒
  548. └─────────────────────────────────────────────────────────────────────────────┘▒
  549.   ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  550. */
  551. LOCAL           ;
  552.     oDlg,       ;
  553.     oLbx,       ;
  554.     btnModify,  ;
  555.     btnDelete,  ;
  556.     btnSearch,  ;
  557.     btnEnd
  558.  
  559.    //──────────────────────────────────────────────────────── File Is Empty
  560.    IF USER->(lastrec()) < 1
  561.       MsgInfo("User file is currently Empty!" + CRLF + ;
  562.           "Please add a User First", "Error")
  563.       return NIL
  564.    ENDIF
  565.  
  566.  
  567.    DEFINE DIALOG oDlg FROM 3, 3 TO 26, 79 TITLE cTitle
  568.  
  569.    @ 0,  1 SAY cListName  OF oDlg
  570.  
  571.    @ 1, 1 LISTBOX oLbx FIELDS USER->Name, USER->User, USER->Title ;
  572.       HEADERS "User Name", "User Id", "User Title"   ;
  573.       SIZE 284, 137  OF oDlg
  574.  
  575.    @ 13,  8 BUTTON btnModify PROMPT "&Modify" OF oDlg SIZE 40, 12
  576.    @ 13, 15 BUTTON btnDelete PROMPT "&Delete" OF oDlg SIZE 40, 12
  577.    @ 13, 22 BUTTON btnSearch PROMPT "&Search" OF oDlg SIZE 40, 12
  578.    @ 13, 29 BUTTON btnEnd    PROMPT "&Exit"   OF oDlg SIZE 40, 12
  579.  
  580.    btnModify:bAction = If( bModify != nil,;
  581.                            { || Eval( bModify ),;
  582.                            oLbx:Refresh(), oLbx:SetFocus( .t. ) },)
  583.  
  584.    btnDelete:bAction = If( bDelete != nil,;
  585.                            { || Eval( bDelete ),;
  586.                            oLbx:Refresh(), oLbx:SetFocus( .t. ) },)
  587.  
  588.    btnSearch:bAction = If( bSearch != nil,;
  589.                            { || Eval( bSearch ),;
  590.                            oLbx:Refresh(), oLbx:SetFocus( .t. ) },)
  591.  
  592.    btnEnd:bAction    = { || oDlg:End() }
  593.  
  594.    ACTIVATE DIALOG oDlg
  595.  
  596. RETURN nil
  597.  
  598.  
  599. STATIC FUNCTION DelUser()
  600. /*
  601. ┌─────────────────────────────────────────────────────────────────────────────┐
  602. │                                                                             │
  603. │ Function   : DelUser()--> NIL                                               │▒
  604. │ Programmer : Jon Kilburn                                                    │▒
  605. │ Date       : March 20, 1994                                                 │▒
  606. │ Modified   :                                                                │▒
  607. │ Purpose    : Nuclear Assault on a user...Total destruction..(Delete)        │▒
  608. │ Parameters : None                                                           │▒
  609. │ Returns    : NIL                                                            │▒
  610. │ Libraries  : FiveWin                                                        │▒
  611. │ DataBases  : USER                                                           │▒
  612. │                                                                             │▒
  613. └─────────────────────────────────────────────────────────────────────────────┘▒
  614.   ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  615. */
  616.  
  617.    IF ! USER->(deleted())
  618.       IF MsgYesNo("Delete this Record?", "Delete")
  619.          IF USER->(rlock())
  620.             USER->(dbdelete())
  621.             USER->(dbunlock())
  622.          ENDIF
  623.       ENDIF
  624.    ELSE
  625.       IF MsgYesNo("Recall this Record?", "Recall")
  626.          IF USER->(rlock())
  627.             USER->(dbrecall())
  628.             USER->(dbunlock())
  629.          ENDIF
  630.       ENDIF
  631.    ENDIF
  632.  
  633. RETURN nil
  634.  
  635.  
  636.  
  637. STATIC FUNCTION FindUser()
  638. /*
  639. ┌─────────────────────────────────────────────────────────────────────────────┐
  640. │                                                                             │
  641. │ Function   : FindUser()--> NIL                                              │▒
  642. │ Programmer : Jon Kilburn                                                    │▒
  643. │ Date       : March 20, 1994                                                 │▒
  644. │ Modified   :                                                                │▒
  645. │ Purpose    : Opens a Search Dialog and SEEKs the for a user                 │▒
  646. │ Parameters : None                                                           │▒
  647. │ Returns    : NIL                                                            │▒
  648. │ Libraries  : FiveWin                                                        │▒
  649. │ DataBases  : USER                                                           │▒
  650. │                                                                             │▒
  651. └─────────────────────────────────────────────────────────────────────────────┘▒
  652.   ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  653. */
  654. LOCAL           ;
  655.       oDlg,     ;
  656.       oSearch,  ;
  657.       oBmp,     ;
  658.       cSearch,  ;
  659.       nRec,     ;
  660.       btnOk,    ;
  661.       btnCancel
  662.  
  663.    nRec := USER->(recno())
  664.    cSearch := space(22)
  665.  
  666.    DEFINE DIALOG oDlg FROM 5,5 TO 11, 38 TITLE "Search"
  667.  
  668.    @ 0.2, 5 SAY "Search for User.." OF oDlg
  669.    @ 1.2, 5 GET cSearch OF oDlg PICTURE "@!"
  670.    @ 0.5, 1 BITMAP oBmp FILE "GLASS.BMP" SIZE 21,21 OF oDlg
  671.  
  672.    //────────────────────────── Define the Action Associated to the OK Button
  673.    @ 2.7, 3 BUTTON "&Ok"  OF oDlg SIZE 44,12                                 ;
  674.    ACTION  (USER->(dbseek(cSearch)),                                         ;
  675.            IF(USER->(eof()), MsgInfo("Name Not Found!", "Search Failed"),),  ;
  676.            oDlg:end())
  677.  
  678.    //────────────────────── Define the Action Associated to the Cancel Button
  679.    @ 2.7, 11 BUTTON "&Cancel" OF oDlg SIZE 44, 12 ACTION oDlg:end()
  680.  
  681.    ACTIVATE DIALOG oDlg CENTERED
  682.  
  683.    IF USER->(eof())
  684.       USER->(dbgoto(nRec))
  685.    ENDIF
  686.  
  687. RETURN nil
  688.  
  689.  
  690.  
  691. STATIC FUNCTION AddMail()
  692. /*
  693. ┌─────────────────────────────────────────────────────────────────────────────┐
  694. │                                                                             │
  695. │ Function   : AddMail()--> NIL                                               │▒
  696. │ Programmer : Jon Kilburn                                                    │▒
  697. │ Date       : March 20, 1994                                                 │▒
  698. │ Modified   :                                                                │▒
  699. │ Purpose    : Opens a Add / Read Dialog                                      │▒
  700. │ Parameters : None                                                           │▒
  701. │ Returns    : NIL                                                            │▒
  702. │ Libraries  : FiveWin                                                        │▒
  703. │ DataBases  : None                                                           │▒
  704. │                                                                             │▒
  705. └─────────────────────────────────────────────────────────────────────────────┘▒
  706.   ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  707. */
  708. LOCAL           ;
  709.       cMemo,    ;
  710.       oMemo,    ;
  711.       oDate,    ;
  712.       cDate,    ;
  713.       oSubject, ;
  714.       cSubject, ;
  715.       oDlg
  716.  
  717.    cMemo    := space(10)
  718.    cDate    := date()
  719.    cSubject := space(20)
  720.  
  721.  
  722.    SET RESOURCES TO "EMAIL.DLL"
  723.    DEFINE DIALOG oDlg RESOURCE "MAIL"  TITLE "Add Mail"
  724.  
  725.    REDEFINE SAY ID ID_DATE    OF oDlg
  726.    REDEFINE SAY ID ID_SUBJECT OF oDlg
  727.  
  728.    REDEFINE GET oDate    VAR cDate ID   ID_GDATE       OF oDlg PICTURE "99/99/99"
  729.    REDEFINE GET oSubject VAR cSubject   ID ID_GSUBJECT OF oDlg PICTURE "@!"
  730.    REDEFINE GET oMemo    VAR cMemo MEMO ID ID_GMEMO    OF oDlg
  731.  
  732.    REDEFINE BUTTON ID ID_SENDB OF oDlg             ;
  733.    ACTION IF(SelectUser(cMemo, cDate, cSubject),   ;
  734.              oDlg:end(), setfocus(oDlg:oMenu))
  735.  
  736.    REDEFINE BUTTON ID ID_CANCELB OF oDlg ACTION oDlg:end()
  737.  
  738.    ACTIVATE DIALOG oDlg CENTER
  739.  
  740.    SET RESOURCES TO
  741.  
  742. RETURN nil
  743.  
  744.  
  745. STATIC FUNCTION SelectUser(cMemo, cDate, cSubject)
  746. /*
  747. ┌─────────────────────────────────────────────────────────────────────────────┐
  748. │                                                                             │
  749. │ Function   : SelectUser( cMemo )--> nReturn                                 │▒
  750. │ Programmer : Jon Kilburn                                                    │▒
  751. │ Date       : March 20, 1994                                                 │▒
  752. │ Modified   :                                                                │▒
  753. │ Purpose    : Reads the USER file into a STATIC array for placement in a     │▒
  754. │              LISTBOX for selection.  After the users to recieve the EMail   │▒
  755. │              have been selected the mail is then copied for each of the     │▒
  756. │              Users who are selected                                         │▒
  757. │ Parameters : cMemo -- The Mail to be sent to each user                      │▒
  758. │ Returns    : NIL                                                            │▒
  759. │ Libraries  : FiveWin                                                        │▒
  760. │ DataBases  : USER                                                           │▒
  761. │                                                                             │▒
  762. └─────────────────────────────────────────────────────────────────────────────┘▒
  763.   ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  764. */
  765. STATIC          ;
  766.       aUsers_
  767.  
  768. LOCAL           ;
  769.       aSel,     ;
  770.       block,    ;
  771.       oDlg,     ;
  772.       oLbx,     ;
  773.       cLbx,     ;
  774.       nRec,     ;
  775.       nPos,     ;
  776.       nReturn
  777.  
  778.    DEFAULT nReturn TO TRUE
  779.    DEFAULT aUsers_ TO {}
  780.  
  781.    IF empty(aUsers_)
  782.       nRec := USER->(recno())
  783.       USER->(dbgotop())
  784.       DO WHILE ! USER->(eof())
  785.          aadd(aUsers_, USER->Name)
  786.          USER->(dbskip())
  787.       ENDDO
  788.       USER->(dbgoto(nRec))
  789.    ENDIF
  790.  
  791.    IF ! empty(cMemo)
  792.       aSel  := {}
  793.       block := { || adel(aSel, nPos), asize(aSel, len(aSel)-1) }
  794.  
  795.       DEFINE DIALOG oDlg RESOURCE "USER_LIST"
  796.  
  797.       /*
  798.       ┌─────────────────────────── N O T I C E ───────────────────────────────┐
  799.       │                                                                       │
  800.       │ The following lines of code are used to handle a multiple selection   │▒
  801.       │ listbox.  The listbox has been defined as a MULTIPLE SELECTION when   │▒
  802.       │ it was created in BORLAND.  Using the ON CHANGE command I scan the    │▒
  803.       │ aSel array to see if I can locate the cLbx variable (ON CHANGE places │▒
  804.       │ the selected text value in the variable declared with the VAR <cLbx>  │▒
  805.       │ statement).  IF cLbx isn't found in the aSel array then add it else   │▒
  806.       │ delete it because it has been de-selected.                            │▒
  807.       │                                                                       │▒
  808.       └───────────────────────────────────────────────────────────────────────┘▒
  809.         ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  810.       */
  811.  
  812.       REDEFINE LISTBOX oLbx VAR cLbx ITEMS aUsers_             ;
  813.       ID ID_LISTBOX ON CHANGE                                  ;
  814.       ( IF((nPos := ascan(aSel, cLbx)) == 0, aadd(aSel, cLbx), ;
  815.             eval(block)) ) OF oDlg
  816.  
  817.       REDEFINE BUTTON ID ID_OKBUT   OF oDlg                    ;
  818.       ACTION ( Send(aSel, cMemo, cDate, cSubject), oDlg:end()  )
  819.  
  820.       REDEFINE BUTTON ID ID_CANCBUT OF oDlg ACTION oDlg:end()
  821.       ACTIVATE DIALOG oDlg CENTER
  822.    ELSE
  823.       tone(440, 2)
  824.       MsgInfo("You Cannot Send An Empty Message" + CRLF +      ;
  825.               "Please Enter Mail or Cancel", "Error")
  826.       nReturn := .F.
  827.    ENDIF
  828.  
  829. RETURN nReturn
  830.  
  831.  
  832.  
  833. STATIC FUNCTION Send(aSel, cMemo, cDate, cSubject)
  834. /*
  835. ┌─────────────────────────────────────────────────────────────────────────────┐
  836. │                                                                             │
  837. │ Function   : Send( aSel )--> NIL                                            │▒
  838. │ Programmer : Jon Kilburn                                                    │▒
  839. │ Date       : March 20, 1994                                                 │▒
  840. │ Modified   :                                                                │▒
  841. │ Purpose    : Scans the aSel array and seeks into the USER database for the  │▒
  842. │              selected users USERID.  The USERID is the key in the MAIL      │▒
  843. │              database.  So create a copy of the Email message for each      │▒
  844. │              Users who is selected                                          │▒
  845. │ Parameters : cMemo -- The Mail to be sent to each user                      │▒
  846. │ Returns    : NIL                                                            │▒
  847. │ Libraries  : FiveWin                                                        │▒
  848. │ DataBases  : MAIL                                                           │▒
  849. │                                                                             │▒
  850. └─────────────────────────────────────────────────────────────────────────────┘▒
  851.   ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  852. */
  853. LOCAL           ;
  854.       i
  855.  
  856.     FOR i := 1 TO len(aSel)
  857.        USER->(dbseek(alltrim(aSel[i])))
  858.        MAIL->(dbappend())
  859.        MAIL->(rlock())
  860.        MAIL->User    := USER->User
  861.        MAIL->Mail    := cMemo
  862.        MAIL->Subject := cSubject
  863.        MAIL->Date    := cDate
  864.        MAIL->(dbunlock())
  865.     NEXT i
  866.  
  867. RETURN nil
  868.  
  869.  
  870.  
  871. STATIC FUNCTION ReadMail()
  872.  
  873. /*
  874. ┌─────────────────────────────────────────────────────────────────────────────┐
  875. │                                                                             │
  876. │ Function   : ReadMail()--> NIL                                              │▒
  877. │ Programmer : Jon Kilburn                                                    │▒
  878. │ Date       : March 20, 1994                                                 │▒
  879. │ Modified   :                                                                │▒
  880. │ Purpose    : Searches for the first Unread message and displays it.         │▒
  881. │ Parameters : None                                                           │▒
  882. │ Returns    : NIL                                                            │▒
  883. │ Libraries  : FiveWin                                                        │▒
  884. │ DataBases  : MAIL                                                           │▒
  885. │                                                                             │▒
  886. └─────────────────────────────────────────────────────────────────────────────┘▒
  887.   ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  888. */
  889. LOCAL           ;
  890.       cMemo,    ;
  891.       oMemo,    ;
  892.       cDate,    ;
  893.       oDate,    ;
  894.       cSubject, ;
  895.       oSubject, ;
  896.       cUser,    ;
  897.       oDlg
  898.  
  899.    cUser := SetRead()
  900.  
  901.    IF cUser == NIL
  902.       MsgStop("No user is currently active!", "Error")
  903.       RETURN nil
  904.    ENDIF
  905.  
  906.    IF ! MAIL->(dbseek(SetRead()))
  907.       MsgStop("You have no mail in your mailbox!", "Error")
  908.       RETURN nil
  909.    ELSE
  910.       IF MAIL->(rlock())
  911.          MAIL->Read := .T.
  912.          MAIL->(dbunlock())
  913.       ENDIF
  914.    ENDIF
  915.  
  916.    cMemo    := MAIL->Mail
  917.    cDate    := MAIL->Date
  918.    cSubject := MAIL->Subject
  919.  
  920.    SET RESOURCES TO "EMAIL.DLL"
  921.    DEFINE DIALOG oDlg RESOURCE "READ"  TITLE "Read Mail"
  922.  
  923.    REDEFINE SAY ID ID_DATE    OF oDlg
  924.    REDEFINE SAY ID ID_SUBJECT OF oDlg
  925.  
  926.    REDEFINE GET oDate    VAR cDate ID   ID_GDATE       OF oDlg PICTURE "99/99/99"
  927.    REDEFINE GET oSubject VAR cSubject   ID ID_GSUBJECT OF oDlg PICTURE "@!"
  928.    REDEFINE GET oMemo    VAR cMemo MEMO ID ID_GMEMO    OF oDlg
  929.  
  930.    REDEFINE BUTTON ID ID_NEXT OF oDlg                     ;
  931.    ACTION ( Next(),                                       ;
  932.             cDate    := MAIL->Date,    oDate:Refresh(),   ;
  933.             cSubject := MAIL->Subject, oSubject:Refresh(),;
  934.             cMemo    := MAIL->Mail,    oMemo:Refresh()    )
  935.  
  936.    REDEFINE BUTTON ID ID_PREV OF oDlg                     ;
  937.    ACTION ( Prev(),                                       ;
  938.             cDate    := MAIL->Date,    oDate:Refresh(),   ;
  939.             cSubject := MAIL->Subject, oSubject:Refresh(),;
  940.             cMemo    := MAIL->Mail,    oMemo:Refresh()    )
  941.  
  942.    REDEFINE BUTTON ID ID_DELETE  OF oDlg ACTION DelMail()
  943.    REDEFINE BUTTON ID ID_CANCELR OF oDlg ACTION oDlg:end()
  944.  
  945.    ACTIVATE DIALOG oDlg CENTER
  946.  
  947.    SET RESOURCES TO
  948.  
  949. RETURN nil
  950.  
  951.  
  952. STATIC FUNCTION DelMail()
  953. /*
  954. ┌─────────────────────────────────────────────────────────────────────────────┐
  955. │                                                                             │
  956. │ Function   : DelMail()--> NIL                                               │▒
  957. │ Programmer : Jon Kilburn                                                    │▒
  958. │ Date       : March 20, 1994                                                 │▒
  959. │ Modified   :                                                                │▒
  960. │ Purpose    : Delete a current Email Record.                                 │▒
  961. │ Parameters : None                                                           │▒
  962. │ Returns    : NIL                                                            │▒
  963. │ Libraries  : FiveWin                                                        │▒
  964. │ DataBases  : MAIL                                                           │▒
  965. │                                                                             │▒
  966. └─────────────────────────────────────────────────────────────────────────────┘▒
  967.   ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  968. */
  969.    IF MsgYesNo("Delete this Mail", "Delete")
  970.       IF MAIL->(rlock())
  971.          MAIL->(dbdelete())
  972.          MAIL->(dbunlock())
  973.       ELSE
  974.          MsgInfo("Unable to delete this Mail", "Error")
  975.       ENDIF
  976.    ENDIF
  977.  
  978. RETURN nil
  979.  
  980.  
  981. STATIC FUNCTION Next()
  982. /*
  983. ┌─────────────────────────────────────────────────────────────────────────────┐
  984. │                                                                             │
  985. │ Function   : Next()--> NIL                                                  │▒
  986. │ Programmer : Jon Kilburn                                                    │▒
  987. │ Date       : March 20, 1994                                                 │▒
  988. │ Modified   :                                                                │▒
  989. │ Purpose    : Skips to the Next Record in the MAIL database and checks to    │▒
  990. │              see if the message belongs to the current user.                │▒
  991. │ Parameters : None                                                           │▒
  992. │ Returns    : NIL                                                            │▒
  993. │ Libraries  : FiveWin                                                        │▒
  994. │ DataBases  : MAIL                                                           │▒
  995. │                                                                             │▒
  996. └─────────────────────────────────────────────────────────────────────────────┘▒
  997.   ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  998. */
  999.     MAIL->(dbskip())
  1000.     IF MAIL->User != SetRead()
  1001.        MsgInfo("No more mail left for you to read", "End of Mail")
  1002.        MAIL->(dbskip(-1))
  1003.     ELSE
  1004.        IF MAIL->(rlock())
  1005.           MAIL->Read := .T.
  1006.           MAIL->(dbunlock())
  1007.        ENDIF
  1008.     ENDIF
  1009.  
  1010. RETURN nil
  1011.  
  1012.  
  1013. STATIC FUNCTION Prev()
  1014. /*
  1015. ┌─────────────────────────────────────────────────────────────────────────────┐
  1016. │                                                                             │
  1017. │ Function   : Prev()--> NIL                                                  │▒
  1018. │ Programmer : Jon Kilburn                                                    │▒
  1019. │ Date       : March 20, 1994                                                 │▒
  1020. │ Modified   :                                                                │▒
  1021. │ Purpose    : Skips to the Prev Record in the MAIL database and checks to    │▒
  1022. │              see if the message belongs to the current user.                │▒
  1023. │ Parameters : None                                                           │▒
  1024. │ Returns    : NIL                                                            │▒
  1025. │ Libraries  : FiveWin                                                        │▒
  1026. │ DataBases  : MAIL                                                           │▒
  1027. │                                                                             │▒
  1028. └─────────────────────────────────────────────────────────────────────────────┘▒
  1029.   ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  1030. */
  1031.     MAIL->(dbskip(-1))
  1032.     IF MAIL->User != SetRead()
  1033.        MsgInfo("No more mail left for you to read", "End of Mail")
  1034.        MAIL->(dbskip())
  1035.     ELSE
  1036.        IF MAIL->(rlock())
  1037.           MAIL->Read := .T.
  1038.           MAIL->(dbunlock())
  1039.        ENDIF
  1040.     ENDIF
  1041.  
  1042. RETURN nil
  1043.  
  1044.  
  1045. FUNCTION PackFile()
  1046. /*
  1047. ┌─────────────────────────────────────────────────────────────────────────────┐
  1048. │                                                                             │
  1049. │ Function   : PackFile()--> NIL                                              │▒
  1050. │ Programmer : Jon Kilburn                                                    │▒
  1051. │ Date       : March 20, 1994                                                 │▒
  1052. │ Modified   :                                                                │▒
  1053. │ Purpose    : Attempts to open the MAIL file in EXCLUSIVE mode and then      │▒
  1054. │              PACKs the file to remove delete Mail.                          │▒
  1055. │ Parameters : None                                                           │▒
  1056. │ Returns    : NIL                                                            │▒
  1057. │ Libraries  : FiveWin                                                        │▒
  1058. │ DataBases  : MAIL                                                           │▒
  1059. │                                                                             │▒
  1060. └─────────────────────────────────────────────────────────────────────────────┘▒
  1061.   ▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  1062. */
  1063.    MAIL->(dbclosearea())
  1064.  
  1065.    //──────────────────────────────── Attempt to open the file in exclusive
  1066.    SELECT 2
  1067.    USE MAIL INDEX MAIL EXCLUSIVE NEW
  1068.  
  1069.    IF neterr()
  1070.       MsgInfo("File is currently in use by another User", "Lock Error")
  1071.       SELECT 2
  1072.       USE MAIL INDEX MAIL SHARED NEW
  1073.       RETURN nil
  1074.    ENDIF
  1075.  
  1076.    PACK
  1077.  
  1078.    MAIL->(dbclosearea())
  1079.  
  1080.    SELECT 2
  1081.    USE MAIL INDEX MAIL SHARED NEW
  1082.  
  1083. RETURN nil
  1084.