home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload / ShartewareOverload.cdr / database / dbcntact.zip / CONTACT.PRG < prev    next >
Text File  |  1987-01-13  |  28KB  |  1,049 lines

  1. ****************************************************************************
  2. *                  CONTACT.PRG - CONTACT TRACKER PROGRAM                   *
  3. ****************************************************************************
  4. *                           COPYRIGHT 1986                                 *
  5. *                         VORTEX DATA SYSTEMS                              *
  6. *                      2515 CAMINO DEL RIO SOUTH                           *
  7. *                              SUITE 301                                   *
  8. *                        SAN DIEGO, CA 92108                               *
  9. *                                                                          *
  10. ****************************************************************************
  11. *      VERSION 3.1     USES NOVELL FILE LOCKS            12/13/86          *
  12. ****************************************************************************
  13. * This program is copyright by Vortex Data Systems, Inc. You are granted
  14. * permission to use this program for your own use, and to modify the source
  15. * code for your own custom use.  You may not sell, modify or provide this
  16. * program as part of any commercial or non commercial venture.
  17. *
  18. * The program uses callable routines from the Ashton-Tate Programmers
  19. * Utilities (CURSOR2,SPORT). If you modify this program you will need to
  20. * have those .OBJ files available to the linker during linking.  The program
  21. * incorporates Novell record and file locks, which will be ignored when
  22. * run in a single user environment.
  23. *
  24. * Hope you find Contact Tracker helpful and productive.
  25.  
  26.  
  27.  
  28. parameters xname
  29. if pcount() = 0
  30.    xname = space(1)
  31. else
  32.    xname = upper(substr(xname,1,1))+trim(substr(xname,2,20))
  33. endif
  34. set bell off
  35. set confirm on
  36. set deleted on
  37. set function 2 to chr(2)
  38. set function 3 to chr(3)
  39. set function 4 to chr(4)
  40. set function 5 to chr(5)
  41. set function 6 to chr(6)
  42. set function 7 to chr(7)
  43. set function 8 to chr(8)
  44. set function 9 to ";"
  45. set function 10 to chr(10)
  46. set exclusive off
  47. more = .T.
  48. string = " "
  49. dstring = date()
  50. store "CONTACT NAME" to d1
  51. store "COMPANY NAME" to d2
  52. store "PRODUCT NAME" to d3
  53. store "DATE        " to d4
  54. store "STATUS      " to d5
  55. frame1 = "╔═╗║╝═╚║"
  56. frame2 = "┌─┐│┘─└│"
  57. repaint = .t.
  58. duperec = .f.
  59. hangup = 'WATH'+chr(13)+chr(10)
  60. do while more
  61.    sele 2
  62.    if file("contact.dbf")
  63.       if net_use("contact",.f.,5)
  64.          set index to I1,I2,I3,I4,I5
  65.       else
  66.          ?? chr(7)
  67.          ? "file not available"
  68.       endif
  69.    endif
  70.    if iscolor()
  71.       color = .t.
  72.    else
  73.       color = .f.
  74.    endif
  75.    if color
  76.       set color to w+/b,r/w,b+
  77.    endif
  78.    set function 10 to chr(10)
  79.    if len(trim(xname)) = 0
  80.       if repaint
  81.          clear
  82.          @ 1,6 say  "╔═══════════════════════════════════════════════════════════════╗"
  83.          @ 2,6 say  "║╔═════════════════════════════════════════════════════════════╗║"
  84.          @ 3,6 say  "║║                     CONTACT TRACKER                         ║║"
  85.          @ 4,6 say  "║╠═════════════════════════════════════════════════════════════╣║"
  86.          @ 5,6 say  "║║                       SEARCH CRITERIA                       ║║"
  87.          @ 6,6 say  "║║                                                             ║║"
  88.          @ 7,6 say  "║║             F2   &D1                               ║║"
  89.          @ 8,6 say  "║║             F3   &D2                               ║║"
  90.          @ 9,6 say  "║║             F4   &D3                               ║║"
  91.          @ 10,6 say "║║             F5   &D4                               ║║"
  92.          @ 11,6 say "║║             F6   &D5                               ║║"
  93.          @ 12,6 say "║╠═════════════════════════════════════════════════════════════╣║"
  94.          @ 13,6 say "║║                       OTHER FUNCTIONS                       ║║"
  95.          @ 14,6 say "║║                                                             ║║"
  96.          @ 15,6 say "║║             F7   ADD A RECORD                               ║║"
  97.          @ 16,6 say "║║             F8   REINDEX DATA FILES                         ║║"
  98.          @ 17,6 say "║║             F9   RUN A DOS PROGRAM                          ║║"
  99.          @ 18,6 say "║║             F10  QUIT                                       ║║"
  100.          @ 19,6 say "║╠═════════════════════════════════════════════════════════════╣║"
  101.          @ 20,6 say "║║                                                             ║║"
  102.          @ 21,6 say "║╚═════════════════════════════════════════════════════════════╝║"
  103.          @ 22,6 say "╚═══════════════════════════════════════════════════════════════╝"
  104.       endif
  105.       
  106.       
  107.       if file("contact.dbf")
  108.       else
  109.          ch = " "
  110.          @ 20,12 say "DATA FILES NO FOUND... DO YOU WANT TO INSTALL Y/N " GET ch pict "!"
  111.          ??  chr(7)
  112.          read
  113.          if ch = "Y"
  114.          else
  115.             @ 20,12 say "NO FILES CREATED                                    "
  116.             do delay
  117.             clear
  118.             quit
  119.          endif
  120.          msg = "CREATING CONTACT TRACKER DATA FILE ... PLEASE WAIT   "
  121.          @ 20,12 get msg
  122.          clear gets
  123.          do creatfil with "CONTACT"
  124.          @ 20,12 say space(53)
  125.          cnf = .T.
  126.          if cnf
  127.             do reindex
  128.             repaint = .f.
  129.             loop
  130.          endif
  131.       endif
  132.       cnf = .F.
  133.       repaint = .f.
  134.       choice = "  "
  135.       @ 20,8 say space(55)
  136.       choice = 0
  137.       @ 20,25 say "YOUR CHOICE ?"
  138.       call CURSOR2 with 'Off'
  139.       do while choice = 0
  140.          time = time()
  141.          @ 3,59 get time
  142.          clear gets
  143.          @ 20,40 say " "
  144.          mtime = time()
  145.          do while mtime = time() .and. choice = 0
  146.             choice = inkey()
  147.          enddo
  148.          if choice > 0
  149.             choice = 0
  150.          endif
  151.       enddo
  152.       call CURSOR2 with 'Normal'
  153.       set confirm on
  154.       set function 9 to trim(string)
  155.       store "                         " to string
  156.       do case
  157.       case choice = -1
  158.          @ 3,53 say space(15)
  159.          @ 20,8 say space(55)
  160.          @ 20,15 say "NAME TO FIND " get string pict "!XXXXXXXXXXXXXXX"
  161.          read
  162.          set order TO 1
  163.          if string # " "
  164.             seek trim(string)
  165.          else
  166.             loop
  167.          endif
  168.       case choice = -2
  169.          @ 3,53 say space(15)
  170.          @ 20,8 say space(55)
  171.          @ 20,13 say "FIRM NAME TO FIND " get string pict "!XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX "
  172.          read
  173.          set order to 2
  174.          if string # " "
  175.             seek trim(string)
  176.          else
  177.             loop
  178.          endif
  179.       case choice= -3
  180.          @ 3,53 say space(15)
  181.          @ 20,8 say space(55)
  182.          @ 20,13 say "PRODUCT NAME TO FIND " get string  pict "!XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX "
  183.          read
  184.          set order to 3
  185.          if string # " "
  186.             seek trim(string)
  187.          else
  188.             loop
  189.          endif
  190.       case choice = -4
  191.          @ 3,53 say space(15)
  192.          @ 20,8 say space(55)
  193.          @ 20,16 say "DATE TO FIND " get dstring
  194.          read
  195.          set order to 4
  196.          seek dstring
  197.          if eof()
  198.             @ 20,15 say "           DATE NOT FOUND..."
  199.             do delay
  200.             loop
  201.          endif
  202.       case choice = -5
  203.          @ 3,53 say space(15)
  204.          @ 20,8 say space(55)
  205.          @ 20,18 say "STATUS TO FIND " get string picture "!"
  206.          read
  207.          set order to 5
  208.          if string # " "
  209.             seek trim(string)
  210.             if eof()
  211.                @ 20,15 say "          STATUS NOT FOUND..."
  212.                do delay
  213.                loop
  214.             endif
  215.          else
  216.             loop
  217.          endif
  218.       case choice = -6
  219.          do addrec
  220.       case choice = -7
  221.          @ 3,53 say space(15)
  222.          do reindex
  223.          loop
  224.       case choice = -8
  225.          @ 3,53 say space(15)
  226.          prog = space(25)
  227.          @ 20,8 say space(55)
  228.          @ 20,15 say "PROGRAM TO RUN " get prog
  229.          read
  230.          if len(trim(prog)) = 0
  231.             loop
  232.          else
  233.             clear
  234.             run &prog
  235.             repaint = .t.
  236.          endif
  237.          loop
  238.       case choice = -9
  239.          set confirm off
  240.          store 0 to choose
  241.          @ 20,15 say "[F10] TO QUIT, OR <CR> RETURN TO PROGRAM "
  242.          call CURSOR2 with 'Off'
  243.          do while choose = 0
  244.             time = time()
  245.             @ 3,59 get time
  246.             clear gets
  247.             @ 20,56 say " "
  248.             mtime = time()
  249.             do while mtime = time() .and. choose = 0
  250.                choose = inkey()
  251.             enddo
  252.          enddo
  253.          call CURSOR2 with 'Normal'
  254.          if choose = -9
  255.             set console off
  256.             clear
  257.             quit
  258.          else
  259.             loop
  260.          endif
  261.       endcase
  262.    else
  263.       seek trim(xname)
  264.       store "               " to string
  265.       store " " to xname
  266.       if eof()
  267.          clear
  268.          @ 10,20,14,40 box frame2
  269.          @ 12,23 say "NAME NOT FOUND "
  270.          loop
  271.       endif
  272.    endif
  273.    if eof()
  274.       @ 3,53 say space(15)
  275.       set function 9 to trim(string)
  276.       store " " to sele
  277.       @ 20,8 say space(55)
  278.       set confirm off
  279.       @ 20,22 say "NOT FOUND, DO YOU WANT TO ADD? " get sele pict "!"
  280.       read
  281.       set confirm on
  282.       if sele = "Y"
  283.          do addrec
  284.       else
  285.          set function 9 to trim(string)
  286.          loop
  287.       endif
  288.    else
  289.       store .f. to label
  290.       store .t. to editing
  291.       store .f. to editmemo
  292.       do frame
  293.       do while editing .and. .not. (eof() .or. bof())
  294.          set function 9 TO dtoc(date())
  295.          set function 6 to chr(27)
  296.          set function 7 TO chr(18)
  297.          set function 8 TO chr(3)
  298.          set function 10 to chr(23)
  299.          if editmemo
  300.             editmemo = .f.
  301.          else
  302.             do format1
  303.             editmemo = .f.
  304.          endif
  305.          key = 0
  306.          call CURSOR2 with 'Off'
  307.          do while key = 0
  308.             time = time()
  309.             @ 2,34 get time
  310.             clear gets
  311.             mtime = time()
  312.             do while mtime = time() .and. key = 0
  313.                key = inkey()
  314.             enddo
  315.          enddo
  316.          call CURSOR2 with 'Normal'
  317.          if key = -9 .or. lastkey() = 27
  318.             editing = .f.
  319.             loop
  320.          endif
  321.          if key = -6
  322.             choice = " "
  323.             save screen
  324.             if color
  325.                set color to w+/r
  326.             endif
  327.             @ 10,15,12,65 box ""
  328.             @ 10,15,12,65 box frame1
  329.             set confirm off
  330.             set scoreboard off
  331.             @ 11,18 say "Do you want to duplicate this record? " get choice pict "!"
  332.             read
  333.             set scoreboard on
  334.             set confirm on
  335.             if color
  336.                set color to w+/b,r/w,b+
  337.             endif
  338.             if choice <> "Y"
  339.                restore screen
  340.                loop
  341.             endif
  342.             duperec = .t.
  343.             store dial1 to mdial1
  344.             store dial2 to mdial2
  345.             store dial3 to mdial3
  346.             store dial4 to mdial4
  347.             store name to mname
  348.             store firm to mfirm
  349.             store address1 to maddress1
  350.             store address2 to maddress2
  351.             store city to mcity2
  352.             store state to mstate
  353.             store zip to mzip
  354.             store phone to mphone
  355.             store product to mproduct
  356.             store date_last to mdate_last
  357.             store date_next to mdate_naxt
  358.             store status to mstatus
  359.             store category to mcategory
  360.             store type to mtype
  361.             do addrec
  362.             do format1
  363.             @ 21,0 say "╔══════════════════════════════════════════════════════════════════════════════╗"
  364.             @ 22,0 say "║  [F5] DIAL [F6] MEMO  [PgUp] Previous Rec  [PgDn] Next Rec  [F10] Continue   ║"
  365.             @ 23,0 say "║     [Alt-F10] Print Options  [Alt-F9] Edit Record    [Alt-F8]  Delete        ║"
  366.             @ 24,0 say "╚══════════════════════════════════════════════════════════════════════════════╝"
  367.             duperec = .f.
  368.             loop
  369.          endif
  370.          if key = -34
  371.             call SPORT with hangup
  372.             loop
  373.          endif
  374.          if key = -4
  375.             do dial
  376.             loop
  377.          endif
  378.          if key = -5
  379.             do memo
  380.          endif
  381.          if key = 18
  382.             skip -1
  383.             loop
  384.          endif
  385.          if key = 3
  386.             skip
  387.             loop
  388.          endif
  389.          if key = -39
  390.             do print
  391.          endif
  392.          if key = -38
  393.             do editrec
  394.          endif
  395.          if key = -37
  396.             do delete
  397.             loop
  398.          endif
  399.          set function 6 to chr(6)
  400.          set function 7 to chr(7)
  401.          set function 8 to chr(8)
  402.          set function 9 to trim(string)
  403.          set function 10 to chr(10)
  404.       enddo
  405.    endif
  406. enddo
  407. clear
  408.  
  409.  
  410.  
  411. procedure label
  412. set console off
  413. set print on
  414. if choice = "C"
  415.    ?
  416.    ?
  417.    ?  "                       CONTACT TRACKER "
  418.    ?
  419.    ?
  420. endif
  421. if choice = "1" .or. choice = "7" .or. choice = "4"
  422.    ?
  423.    ?
  424.    ?
  425.    ?
  426.    ?
  427.    ?
  428.    ?
  429.    ?
  430. endif
  431. if len(trim(name)) > 0 .and. cont
  432.    ? space(lm)+trim(substr(name,at(',',name)+2,len(name))) + " " +  substr(name,1,at(',',name)-1)
  433. endif
  434. if len(trim(firm)) > 0 .and. comp
  435.    ? space(lm)+firm
  436. endif
  437. ? space(lm)+address1
  438. if len(trim(address2)) > 0
  439.    ? space(lm)+address2
  440. endif
  441. ? space(lm)+trim(city)+", "+state+" "+zip
  442. ?
  443. if choice = "3" .or. choice = "6" .or. choice = "9" .or. choice = "C"
  444.    ? space(lm+5) + phone
  445.    ?
  446.    ? product
  447.    ?
  448.    ? "Category  " + category
  449.    ? "Status    " + status
  450.    ? "Type      " + type
  451.    ?
  452. endif
  453. if choice = "C"
  454.    ?
  455.    ? "========================NOTES================================================"
  456.    ?
  457.    
  458.    ? memo
  459. endif
  460. set console on
  461. set print off
  462. store .f. to label
  463.  
  464.  
  465.  
  466.  
  467. procedure delay
  468. zz=1
  469. do while zz < 250
  470.    zz= zz+1
  471. enddo
  472. return
  473.  
  474.  
  475.  
  476. procedure frame
  477. repaint = .t.
  478. clear
  479. @ 1,0 say  "╔══════════════════════════════════════════╦═══════════════════════════════════╗"
  480. @ 2,0 say  "║   CONTACT TRACKER DATA BASE              ║                                   ║"
  481. @ 3,0 say  "╠══════════════════════════════════════════╩═══════════════════════════════════╣"
  482. @ 4,0 say  "║"
  483. @ 4,79 say "║"
  484. @ 5,0 say  "║"
  485. @ 5,79 say "║"
  486. @ 6,0 say  "║"
  487. @ 6,79 say "║"
  488. @ 7,0 say  "║"
  489. @ 7,79 say "║"
  490. @ 8,0 say  "║"
  491. @ 8,79 say "║"
  492. @ 9,0 say  "║"
  493. @ 9,79 say "║"
  494. @ 10,0 say "║"
  495. @ 10,79 say "║"
  496. @ 11,0 say  "║"
  497. @ 11,79 say "║"
  498. @ 12,0 say  "║"
  499. @ 12,79 say "║"
  500. @ 13,0 say  "║"
  501. @ 13,79 say "║"
  502. @ 14,0 say  "╠"
  503. @ 14,1 say  "══════════════════════════════════════════════════════════════════════════════"
  504. @ 14,79 say "╣"
  505. @ 15,0 say  "║"
  506. @ 15,79 say "║"
  507. @ 16,0 say  "║"
  508. @ 16,79 say "║"
  509. @ 17,0 say  "║"
  510. @ 17,79 say "║"
  511. @ 18,0 say  "║"
  512. @ 18,79 say "║"
  513. @ 19,0 say  "║"
  514. @ 19,79 say "║"
  515. @ 20,0 say  "║"
  516. @ 20,79 say "║"
  517. @ 21,0 say "╔══════════════════════════════════════════════════════════════════════════════╗"
  518. @ 22,0 say "║  [F5] DIAL [F6] MEMO  [PgUp] Previous Rec  [PgDn] Next Rec  [F10] Continue   ║"
  519. @ 23,0 say "║     [Alt-F10] Print Options  [Alt-F9] Edit Record    [Alt-F8]  Delete        ║"
  520. @ 24,0 say "╚══════════════════════════════════════════════════════════════════════════════╝"
  521. @ 4,1 say   "                                                                             "
  522. @ 5,1 say "    NAME                                                                     "
  523. @ 6,1 say "                                                                             "
  524. @ 7,1 say "    COMPANY                                                                  "
  525. @ 8,1 say "    ADDRESS                                                                  "
  526. @ 9,1 say "                                                                             "
  527. @ 10,1 say "                                                                             "
  528. @ 11,1 say "    PHONE                                                                    "
  529. @ 12,1 say "    PRODUCT                                                                  "
  530. @ 13,1 say "                                                                             "
  531. @ 15,1 say "    LAST CONTACT               DIAL NOS                                      "
  532. @ 16,1 say "    NEXT CALL                                                                "
  533. @ 17,1 say "    STATUS CODE                                                              "
  534. @ 18,1 say "    CATEGORY                                                                 "
  535. @ 19,1 say "    TYPE                                                                     "
  536. @ 20,1 say "                                                                             "
  537.  
  538.  
  539.  
  540.  
  541. procedure format1
  542. if color
  543.    set color to GR+/B
  544. endif
  545. *@ 2,45 say dial1
  546. @ 5,19 say space(59)
  547. if at(",",name) = 0
  548.    @ 5,19 say name
  549. else
  550.    @ 5,19 say trim(substr(name,at(',',name)+2,len(name))) + " " +  substr(name,1,at(',',name)-1)
  551. endif
  552. @ 7,19 say firm
  553. @ 8,19 say address1
  554. if len(trim(address2)) = 0
  555.    @ 9,19 say space(40)
  556.    if len(trim(city)) = 0
  557.       @ 10,19 say space(40)
  558.    else
  559.       @ 09,19 say trim(city) + ", " + state + " " + zip
  560.       @ 10,19 say space(40)
  561.    endif
  562. else
  563.    @ 9,19 say space(40)
  564.    @ 9,19 say address2
  565.    @ 10,19 say space(40)
  566.    if len(trim(city)) = 0
  567.    else
  568.       @ 10,19 say trim(city) + ", " + state + " " + zip
  569.    endif
  570. endif
  571. @ 11,19 say phone
  572. @ 12,19 say product
  573. if date_last <> "  /  /  "
  574.    @ 15,19 say date_last
  575. else
  576.    @ 15,19 say space(8)
  577. endif
  578. if date_next <> "  /  /  "
  579.    @ 16,19 say date_next
  580. else
  581.    @ 16,19 say space(8)
  582. endif
  583. @ 17,19 say status pict "!!!"
  584. @ 18,19 say category pict "!!!"
  585. @ 19,19 say type pict "!!!"
  586. @ 15,45 say dial1
  587. @ 16,45 say dial2
  588. @ 17,45 say dial3
  589. @ 18,45 say dial4
  590. @ 23,76 say " "
  591. if color
  592.    set color to w+/b,r/w,b+
  593. endif
  594.  
  595.  
  596.  
  597.  
  598. procedure format2
  599. @ 20,40 say space(38)
  600. @ 2,34 say space(8)
  601. *@ 2,45 get dial1
  602. @ 5,19 get name pict "!XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
  603. @ 5,58 say "Last, First M."
  604. @ 7,19 get firm pict "!XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
  605. @ 8,19 get address1
  606. @ 9,19 get address2
  607. @ 10,19 get city pict "!XXXXXXXXXXXXXXXXXXXX"
  608. @ 10,41 get state pict "!!"
  609. @ 10,44 get zip pict "99999x9999"
  610. @ 11,19 get phone
  611. @ 12,19 get product pict "!XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"
  612. @ 15,19 get date_last pict "99/99/99"
  613. @ 16,19 get date_next pict "99/99/99"
  614. @ 17,19 get status pict "!!!"
  615. @ 18,19 get category pict "!!!"
  616. @ 19,19 get type pict "!!!"
  617. @ 15,45 get dial1
  618. @ 16,45 get dial2
  619. @ 17,45 get dial3
  620. @ 18,45 get dial4
  621. @ 22,1 say space(60)
  622. @ 23,1 say space(72)
  623.  
  624.  
  625.  
  626.  
  627. procedure reindex
  628. if net_use("contact",.t.,5)
  629.    msg = "REINDEXING DATA FILES ... PLEASE WAIT"
  630.    @ 20,15 get msg
  631.    clear gets
  632.    index on name to I1
  633.    index on firm to I2
  634.    index on product to I3
  635.    index on ctod(date_next) to I4
  636.    index on status to I5
  637.    unlock
  638.    set index to I1,I2,I3,I4,I5
  639.    @ 20,15 say space(50)
  640. else
  641.    msg = "UNABLE TO REINDEX DATA FILES, FILE IS ALREADY IN USE "
  642.    @ 20,12 get msg
  643.    ?? chr(7)
  644.    clear gets
  645.    do delay
  646.    @ 20,12 say space(54)
  647. endif
  648.  
  649.  
  650.  
  651.  
  652.  
  653. procedure addrec
  654. clear
  655. set order to 1
  656. set function 7 to chr(18)
  657. set function 8 TO chr(3)
  658. set function 10 TO chr(23)
  659. set function 9 TO dtoc(date())
  660. if add_rec(5)
  661. else
  662.    msg = "CANNOT ADD A RECORD NOW, FILE IS LOCKED"
  663.    @ 20,22 get msg
  664.    ?? CHR(7)
  665.    do delay
  666.    @ 20,22 say space(45)
  667.    return
  668. endif
  669. clear
  670. do frame
  671. if duperec
  672.    replace dial1 with mdial1
  673.    replace dial2 with mdial2
  674.    replace dial3 with mdial3
  675.    replace dial4 with mdial4
  676.    replace name with mname
  677.    replace firm with mfirm
  678.    replace address1 with maddress1
  679.    replace address2 with maddress2
  680.    replace city with mcity2
  681.    replace state with mstate
  682.    replace zip with mzip
  683.    replace phone with mphone
  684.    replace product with mproduct
  685.    replace date_last with mdate_last
  686.    replace date_next with mdate_naxt
  687.    replace status with mstatus
  688.    replace category with mcategory
  689.    replace type with mtype
  690. endif
  691. do format2
  692. read
  693. unlock
  694. set function 10 to chr(10)
  695. set function 9 to trim(string)
  696. set function 8 to chr(8)
  697. set function 7 to chr(7)
  698.  
  699.  
  700. procedure creatfil
  701. create contact
  702. F1 =  "DATE_LAST   C 8 "
  703. F2 =  "DATE_NEXT   C 8 "
  704. F3 =  "NAME        C 35"
  705. F4 =  "FIRM        C 35"
  706. F5 =  "ADDRESS1    C 35"
  707. F6 =  "ADDRESS2    C 35"
  708. F7 =  "CITY        C 21"
  709. F8 =  "STATE       C 2 "
  710. F9 =  "ZIP         C 10"
  711. F10 = "PRODUCT     C 35"
  712. F11 = "PHONE       C 17"
  713. F12 = "DIAL1       C 30"
  714. F13 = "DIAL2       C 30"
  715. F14 = "DIAL3       C 30"
  716. F15 = "DIAL4       C 30"
  717. F16 = "STATUS      C 1 "
  718. F17 = "CATEGORY    C 3 "
  719. F18 = "TYPE        C 3 "
  720. F19 = "EDIT        L 1 "
  721. F20 = "MEMO        M 10"
  722. count = 1
  723. do while count <= 20
  724.    store if(count <= 9, str(count,1) , str(count,2) ) to cnt
  725.    append blank
  726.    x="F"+cnt
  727.    replace field_name with substr(&X,1,10),field_type with substr(&X,13,1)
  728.    replace field_len with val(substr(&X,15,2))
  729.    count = count + 1
  730. enddo
  731. create C_455 from contact
  732. use
  733. delete file contact.dbf
  734. delete file contact.dbt
  735. rename  C_455.DBF to CONTACT.DBF
  736. rename  C_455.DBT to CONTACT.DBT
  737.  
  738.  
  739.  
  740.  
  741. procedure print
  742. save screen
  743. @ 12,15,23,65 box ""
  744. if color
  745.    set color to r/w
  746. endif
  747. @ 12,15,23,65 box ""
  748. @ 12,15,23,65 box frame2
  749. @ 12,28 say " PRINT CHOICES "
  750. choice = " "
  751. do while choice = " "
  752.    @ 14,18 say "         Standard Envelope   Label    Rolodex"
  753.    @ 16,18 say "Company only   [1]            [2]        [3] "
  754.    @ 17,18 say "Contact only   [4]            [5]        [6] "
  755.    @ 18,18 say "Both           [7]            [8]        [9] "
  756.    @ 19,16 say replicate(chr(196),49)
  757.    @ 20,18 say "Complete record  [C]   Exit w/o printing [0] "
  758.    set console off
  759.    wait " " to choice
  760.    if color
  761.       set color to w+/b,r/w,b+
  762.    endif
  763.    if len(trim(choice)) = 0
  764.       choice = "0"
  765.       loop
  766.    endif
  767.    choice = upper(choice)
  768.    set console on
  769.    comp = .t.
  770.    cont = .t.
  771.    do case
  772.    case choice = '0'
  773.       loop
  774.    case choice = "1"
  775.       lm = 30
  776.       cont = .f.
  777.    case choice = '2'.or. choice = '3'
  778.       cont = .f.
  779.       lm = 0
  780.    case choice = '4'
  781.       lm = 30
  782.       comp = .f.
  783.    case choice = '5'
  784.       lm = 0
  785.       comp = .f.
  786.    case choice = '6'
  787.       lm = 0
  788.       comp = .f.
  789.    case choice = '7'
  790.       lm = 30
  791.    case choice = '8' .or. choice = '9' .or. choice = 'C'
  792.       lm = 0
  793.    otherwise
  794.       choice = " "
  795.       loop
  796.    endcase
  797.    if choice <> "0"
  798.       do label
  799.    endif
  800.    restore screen
  801.    loop
  802. enddo
  803. restore screen
  804. return
  805.  
  806.  
  807.  
  808. procedure delete
  809. sure = " "
  810. set confirm off
  811. @ 19,45 say "Delete? Y/N " get sure pict "!"
  812. read
  813. set confirm on
  814. if sure = "Y"
  815.    if rec_lock(5)
  816.       delete
  817.       unlock
  818.       @ 19,45 say "Record is deleted "
  819.       ?? chr(7)
  820.       do delay
  821.       @ 19,45 say space(20)
  822.    else
  823.       msg = "Cannot delete  "
  824.       @ 19,45 get msg
  825.       clear gets
  826.       ?? chr(7)
  827.       do delay
  828.       @ 19,45 say space(15)
  829.    endif
  830. else
  831.    @ 19,45 say space(20)
  832. endif
  833.  
  834.  
  835.  
  836. procedure memo
  837. lock = .t.
  838. do while lock
  839.    if rec_lock(5)
  840.       save screen
  841.       clear
  842.       @ 2,1,23,78 box frame2
  843.       @ 2,36 say "NOTES"
  844.       store trim(substr(name,at(',',name)+2,len(name))) + " " +  substr(name,1,at(',',name)-1) to mname
  845.       @ 1,10 get mname
  846.       clear gets
  847.       replace memo with memoedit(memo,3,3,22,77,.t.)
  848.       unlock
  849.       restore screen
  850.       lock = .f.
  851.       editmemo = .t.
  852.       loop
  853.    else
  854.       store " Record is locked. (R)etry or (E)xit "  to msg
  855.       @ 20,40 get msg
  856.       ?? chr(7)
  857.       clear gets
  858.       set console off
  859.       wait to x
  860.       set console on
  861.       if upper(x) = "R"
  862.          loop
  863.       else
  864.          @ 20,40 say space(38)
  865.          exit
  866.       endif
  867.    endif
  868.    editmemo = .f.
  869. enddo
  870.  
  871.  
  872.  
  873. procedure dial
  874.  
  875. save screen
  876. tst = space(30)
  877. if dial1 = tst .and. dial2 = tst .and. dial3 = tst .and. dial4 = tst
  878.    @ 12,40 say "NO NUMBERS TO DIAL"
  879.    ?? chr(7)
  880.    do delay
  881.    @ 12,40 say "                  "
  882.    return
  883. endif
  884. if dial2 = tst .and. dial3 = tst .and. dial4 = tst
  885.   opt = 1
  886. else
  887.    msg1 =  " PICK NUMBER TO DIAL AND HIT RETURN   "
  888.    msg2 = "   (ESCAPE TO ABORT)                  "
  889.    @ 12,40 get msg1
  890.    @ 13,40 get msg2
  891.    clear gets
  892.    @ 15,45 prompt dial1
  893.    if dial2 <> "     "
  894.       @ 16,45 prompt dial2
  895.    endif
  896.    if dial3 <> "     "
  897.       @ 17,45 prompt dial3
  898.    endif
  899.    if dial4 <> "     "
  900.       @ 18,45 prompt dial4
  901.    endif
  902.    menu to opt
  903.    if opt = 0
  904.       restore screen
  905.       return
  906.    endif
  907. endif
  908. dialno = "DIAL"+str(opt,1)
  909. dial = 'WATDT' + &DIALNO + chr(13) + chr(10)  && for smartmodem
  910. if color
  911.    set color to w+/r
  912. endif
  913. @ 09,10,15,62 box ""
  914. @ 09,10,15,62 box frame1
  915. @ 11,12 say "Now dialing  " + trim(substr(name,at(',',name)+2,len(name))) + " " +  substr(name,1,at(',',name)-1)
  916. @ 12,12 say "Phone #      " + &dialno
  917. call SPORT with 'P1'
  918. call SPORT with 'V 1200, N, 8, 1'
  919. call SPORT with DIAL
  920. msg = "  Press ESC when your party answers or to HANG UP  "
  921. @ 14,11 get msg
  922. clear gets
  923. if color
  924.    set color to w+/b,r/w,b+
  925. endif
  926. choice = 0
  927. call CURSOR2 with 'Off'
  928. do while choice <> 27
  929.    time = time()
  930.    @ 2,34 get time
  931.    clear gets
  932.    @ 23,57 say " "
  933.    mtime = time()
  934.    do while mtime = time() .and. choice = 0
  935.       choice = inkey()
  936.    enddo
  937. enddo
  938. call SPORT with HANGUP
  939. restore screen
  940. call CURSOR2 with 'Normal'
  941.  
  942.  
  943.  
  944.  
  945. procedure editrec
  946. do while .t.
  947.    if rec_lock(5)
  948.       do format2
  949.       read
  950.       unlock
  951.       @ 21,0 say "╔══════════════════════════════════════════════════════════════════════════════╗"
  952.       @ 22,0 say "║  [F5] DIAL [F6] MEMO  [PgUp] Previous Rec  [PgDn] Next Rec  [F10] Continue   ║"
  953.       @ 23,0 say "║     [Alt-F10] Print Options  [Alt-F9] Edit Record    [Alt-F8]  Delete        ║"
  954.       @ 24,0 say "╚══════════════════════════════════════════════════════════════════════════════╝"
  955.       exit
  956.    else
  957.       store " Record is locked. (R)etry or (E)xit "  to msg
  958.       @ 20,40 get msg
  959.       ?? chr(7)
  960.       clear gets
  961.       set console off
  962.       wait to x
  963.       set console on
  964.       if upper(x) = "R"
  965.          loop
  966.       else
  967.          @ 20,40 say space(38)
  968.          exit
  969.       endif
  970.    endif
  971. enddo
  972.  
  973.  
  974.  
  975. ** USER DEFINED FUNCTIONS
  976.  
  977. FUNCTION NET_USE
  978. PARAMETERS file, ex_use, wait
  979. PRIVATE forever
  980. forever = (wait = 0)
  981. DO WHILE (forever .OR. wait > 0)
  982.    IF ex_use
  983.       USE &file EXCLUSIVE
  984.    ELSE
  985.       USE &file
  986.    ENDIF
  987.    IF .NOT. NETERR()
  988.       RETURN (.T.)
  989.    ENDIF
  990.    INKEY(1)
  991.    wait = wait - 1
  992. ENDDO
  993. RETURN (.F.)
  994.  
  995.  
  996.  
  997. FUNCTION FIL_LOCK
  998. PARAMETERS wait
  999. PRIVATE forever
  1000. IF FLOCK()
  1001.    RETURN (.T.)
  1002. ENDIF
  1003. forever = (wait = 0)
  1004. DO WHILE (forever .OR. wait > 0)
  1005.    INKEY(.5)
  1006.    wait = wait - .5
  1007.    IF FLOCK()
  1008.       RETURN (.T.)
  1009.    ENDIF
  1010. ENDDO
  1011. RETURN (.F.)
  1012.  
  1013.  
  1014. FUNCTION REC_LOCK
  1015. PARAMETERS wait
  1016. PRIVATE forever
  1017. IF RLOCK()
  1018.    RETURN (.T.)
  1019. ENDIF
  1020. forever = (wait = 0)
  1021. DO WHILE (forever .OR. wait > 0)
  1022.    IF RLOCK()
  1023.       RETURN (.T.)
  1024.    ENDIF
  1025.    INKEY(.5)
  1026.    wait = wait - .5
  1027. ENDDO
  1028. RETURN (.F.)
  1029.  
  1030.  
  1031. FUNCTION ADD_REC
  1032. PARAMETERS wait
  1033. PRIVATE forever
  1034. APPEND BLANK
  1035. IF .NOT. NETERR()
  1036.    RETURN (.T.)
  1037. ENDIF
  1038. forever = (wait = 0)
  1039. DO WHILE (forever .OR. wait > 0)
  1040.    APPEND BLANK
  1041.    IF .NOT. NETERR()
  1042.       RETURN .T.
  1043.    ENDIF
  1044.    INKEY(.5)
  1045.    wait = wait - .5
  1046. ENDDO
  1047. RETURN (.F.)
  1048.  
  1049.