home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / lb091.zip / CONTACT.BAS < prev    next >
BASIC Source File  |  1994-05-17  |  7KB  |  267 lines

  1.  
  2.     nomainwin
  3.  
  4.     dim name$(500)
  5.     dim stage$(7)
  6.     stage$(0) = "All"
  7.     stage$(1) = "Initial Phone Call"
  8.     stage$(2) = "Opening Mailer"
  9.     stage$(3) = "Follow Up Call"
  10.     stage$(4) = "Special Offer Mailer"
  11.     stage$(5) = "Closing Phone Call"
  12.  
  13.     gosub [loadNames]
  14.     gosub [openMainWindow]
  15.  
  16.  
  17.  
  18. [inputLoop]
  19.  
  20.     input r$
  21.     goto [inputLoop]
  22.  
  23.  
  24. [openMainWindow]
  25.  
  26.     WindowWidth = 510
  27.     WindowHeight = 350
  28.  
  29.     'open the main window
  30.  
  31.     button #main, " &OK ", [acceptEntry], UL, 450, 290
  32.  
  33.     statictext #main, "Contacts", 10, 10, 60, 20
  34.     listbox #main.contacts, name$(, [editName], 10, 35, 160, 120
  35.     statictext #main, "Filter Contacts", 10, 170, 160, 20
  36.     combobox #main.filter, stage$(, [loadNamesFiltered], 10, 190, 160, 120
  37.     button #main, "&Edit", [editName], UL, 10, 290
  38.     button #main, "&Add", [addName], UL, 55, 290
  39.  
  40.     statictext #main, "Name", 200, 10, 60, 20
  41.       textbox #main.name, 265, 10, 225, 25
  42.     statictext #main, "Address", 200, 40, 60, 20
  43.       textbox #main.addr, 265, 40, 225, 25
  44.     statictext #main, "City", 200, 70, 60, 20
  45.       textbox #main.city, 265, 70, 225, 25
  46.     statictext #main, "State", 200, 100, 60, 20
  47.       textbox #main.state, 265, 100, 40, 25
  48.     statictext #main, "Zip",  330, 100, 40, 20
  49.       textbox #main.zip, 380, 100, 108, 25
  50.     statictext #main, "Phone #", 200, 130, 60, 20
  51.       textbox #main.phone, 265, 130, 225, 25
  52.     statictext #main, "Comment", 200, 160, 60, 20
  53.       textbox #main.memo, 265, 160, 225, 25
  54.     statictext #main, "Stage", 200, 190, 60, 20
  55.       combobox #main.stage, stage$(, [inputLoop], 265, 190, 225, 110
  56.  
  57.     open "Liberty Contact Manager" for dialog as #main
  58.  
  59.     print #main, "trapclose [quit]"
  60.     print #main.filter, "select All";
  61.     print #main.contacts, "singleclickselect"
  62.  
  63.     return
  64.  
  65.  
  66.  
  67. [loadNames]
  68.  
  69.     open "contact3.dat" for random as #contacts len = 650
  70.  
  71.     field #contacts, 20 as name$, 20 as address$, 15 as city$, 2 as state$, 10 as zip$, 15 as phone$, 20 as stage$, 500 as memo$, 48 as fill$
  72.  
  73.     if eof(#contacts) <> 0 then close #contacts : gosub [initializeNames] : goto [loadNames]
  74.  
  75.     get #contacts, 1
  76.     contactCount = val(name$)
  77.     if contactCount = 0 then close #contacts : return
  78.  
  79.     for index = 2 to contactCount + 1
  80.  
  81.         gettrim #contacts, index
  82.         name$(index - 1) = name$
  83.  
  84.     next index
  85.  
  86.     close #contacts
  87.  
  88.     return
  89.  
  90.  
  91.  
  92. [loadNamesFiltered]
  93.  
  94.     print #main.filter, "selection?"
  95.     input #main.filter, filter$
  96.  
  97.     open "contact3.dat" for random as #contacts len = 650
  98.  
  99.     field #contacts, 20 as name$, 20 as address$, 15 as city$, 2 as state$, 10 as zip$, 15 as phone$, 20 as stage$, 500 as memo$, 48 as fill$
  100.  
  101.     get #contacts, 1
  102.     contactCount = val(name$)
  103.     if contactCount = 0 then close #contacts : goto [inputLoop]
  104.  
  105.     for index = 2 to contactCount + 1
  106.  
  107.         gettrim #contacts, index
  108.         if filter$ = stage$ or filter$ = "All" then name$(index - 1) = name$ else name$(index - 1) = ""
  109.  
  110.     next index
  111.  
  112.     close #contacts
  113.     print #main.contacts, "reload"
  114.  
  115.     goto [inputLoop]
  116.  
  117.  
  118.  
  119. [initializeNames]
  120.  
  121.     open "contact3.dat" for random as #contacts len = 650
  122.  
  123.     field #contacts, 20 as name$, 20 as address$, 15 as city$, 2 as state$, 10 as zip$, 15 as phone$, 20 as stage$, 500 as memo$, 48 as fill$
  124.  
  125.     name$ = "4"
  126.     put #contacts, 1
  127.     name$ = "Carl Gundel"
  128.     stage$ = "Initial Phone Call"
  129.     put #contacts, 2
  130.     name$ = "Ray Lukas"
  131.     stage$ = "Special Offer Mailer"
  132.     put #contacts, 3
  133.     name$ = "Bill West"
  134.     stage$ = "Initial Phone Call"
  135.     put #contacts, 4
  136.     name$ = "Alex Guevara"
  137.     stage$ = "Special Offer Mailer"
  138.     put #contacts, 5
  139.  
  140.     close #contacts
  141.  
  142.     return
  143.  
  144.  
  145.  
  146. [editName]
  147.  
  148.     addName = 0
  149.  
  150.     print #main.contacts, "selection?"
  151.     input #main.contacts, selection$
  152.     if selection$ = "" then [inputLoop]
  153.  
  154.     recIndex = 0
  155.     for index = 1 to contactCount
  156.         if selection$ = name$(index) then recIndex = index
  157.     next  index
  158.  
  159.     if recIndex = 0 then [inputLoop]  'This should never need to happen
  160.  
  161.     gosub [getContactRecord]
  162.     print #main.name, name$
  163.     print #main.addr, address$
  164.     print #main.city, city$
  165.     print #main.state, state$
  166.     print #main.zip, zip$
  167.     print #main.phone, phone$
  168.     print #main.stage, "selectindex 7"
  169.     for index = 0 to 5
  170.         if stage$(index) = stage$ then print #main.stage, "selectindex "; index + 1
  171.     next index
  172.     print #main.memo, "!cls" ;
  173.     print #main.memo, memo$ ;
  174.  
  175.     goto [inputLoop]
  176.  
  177.  
  178. [addName]
  179.  
  180.     addName = 1
  181.  
  182.     print #main.name, ""
  183.     print #main.addr, ""
  184.     print #main.city, ""
  185.     print #main.state, ""
  186.     print #main.zip, ""
  187.     print #main.phone, ""
  188.     print #main.stage, "selectindex 2"
  189.     print #main.memo, ""
  190.  
  191.     goto [inputLoop]
  192.  
  193.  
  194.  
  195.  
  196. [getContactRecord]
  197.  
  198.     open "contact3.dat" for random as #contacts len = 650
  199.     field #contacts, 20 as name$, 20 as address$, 15 as city$, 2 as state$, 10 as zip$, 15 as phone$, 20 as stage$, 500 as memo$, 48 as fill$
  200.  
  201.     gettrim #contacts, recIndex + 1
  202.  
  203.     close #contacts
  204.  
  205.     return
  206.  
  207.  
  208.  
  209. [acceptEntry]
  210.  
  211.     print #main.name, "!contents?";
  212.     input #main.name, name$
  213.     print #main.addr, "!contents?";
  214.     input #main.addr, address$
  215.     print #main.city, "!contents?";
  216.     input #main.city, city$
  217.     print #main.state, "!contents?";
  218.     input #main.state, state$
  219.     print #main.zip, "!contents?";
  220.     input #main.zip, zip$
  221.     print #main.phone, "!contents?";
  222.     input #main.phone, phone$
  223.     print #main.stage, "selection?";
  224.     input #main.stage, stage$
  225.     print #main.memo, "!contents?";
  226.     input #main.memo, memo$
  227.  
  228.  
  229.     if addName = 1 then contactCount = contactCount + 1 : recIndex = contactCount
  230.  
  231.     name$(recIndex) = name$
  232.     print #main.contacts, "reload"
  233.  
  234.     gosub [saveContactRecord]
  235.     addName = 0
  236.  
  237.     goto [loadNamesFiltered]
  238.  
  239.  
  240.  
  241. [saveContactRecord]
  242.  
  243.     open "contact3.dat" for random as #contacts len = 650
  244.     field #contacts, 20 as name$, 20 as address$, 15 as city$, 2 as state$, 10 as zip$, 15 as phone$, 20 as stage$, 500 as memo$, 48 as fill$
  245.     put #contacts, recIndex + 1
  246.     close #contacts
  247.  
  248.     if addName = 0 then return
  249.  
  250.     open "contact3.dat" for random as #contacts len = 650
  251.     field #contacts, 20 as count$, 630 as fill$
  252.     count$ = str$(contactCount)
  253.     put #contacts, 1
  254.     close #contacts
  255.  
  256.     return
  257.  
  258. [quit]
  259.  
  260.     confirm "Quit Contact Manager?"; quit$
  261.     if quit$ <> "yes" then [inputLoop]
  262.     close #main
  263.     end
  264.  
  265.  
  266.  
  267.