home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Misc / HYPERBOOK2.DMS / in.adf / Applications / AddressBook.hb (.txt) < prev    next >
Encoding:
HyperBook  |  1990-10-07  |  15.8 KB  |  315 lines

  1. e/* F1_Edit or Add - This exists only to implement the F1 shortcut */
  2. call activate('Edit button'())
  3. F1_Edit or Add
  4. d/* F2_Browse - This exists solely to implement the F2 shortcut */
  5. call activate('Browse button'())
  6.     F2_Browse
  7. %db = 'Database'()
  8. if numelements(db) = 0 then EXIT
  9. text = inputstring('Enter search text', '')
  10. if text = '' then EXIT
  11. it = objectnumber(db,1)
  12. cr = '0a'X
  13. do forever
  14.    it = searchitems(it, text)
  15.    if it = '' then do
  16.       call inform(cr || 'Not found' || cr)
  17.       EXIT
  18.       end
  19.    output = 'Format record'(getitemtext(it)) cr 'Search again?' cr
  20.    if getresponse(output) then do
  21.       it = getnext(it)
  22.       if it = '' then do
  23.          call inform(cr || 'Not found' || cr)
  24.          EXIT
  25.          end
  26.       end
  27.    else
  28.       EXIT
  29.    end
  30. F3_Search for item
  31. db = 'Database'()
  32. ndx = 'Lastname index'()
  33. if numelements(db) = 0 then EXIT
  34. it = selectitem(db, 'Select a record to delete')
  35. tx = getitemtext(it)
  36. cr = '0a'X
  37. output = 'Format record'(tx) cr 'Really delete this record?' cr
  38. if getresponse(output) then do
  39.    call delete(it)
  40.    parse var tx name ';'
  41.    name = trim(name)
  42.    name = word(name, words(name))
  43.    it = searchitems(ndx, name)
  44.    if it = '' then EXIT
  45.    if abbrev(getitemtext(it), name) then
  46.       call delete(it)
  47.    end
  48. F4_Delete record
  49. /* Sort 'Database' list and, subordinately, the 'LastName Index' list (if
  50.    it exists).
  51. db  = 'Database'()
  52. ndx = 'LastName Index'()
  53. if numelements(db) ~= numelements(ndx) then
  54.    call inform(' Index must be rebuilt before database can be sorted. ')
  55. else do
  56.    call interactive(0)
  57.    call sortlist(db, ndx)
  58.    call setborder(ndx,0)
  59.    call listscroll(objectnumber(db,1))
  60.    end
  61. F5_Sort by first names
  62. l/* Sort 'Database' list subordinate to sorting 'LastName Index' list */
  63. db  = 'Database'()
  64. ndx = 'LastName Index'()
  65. if numelements(ndx) ~= numelements(db) then
  66.    call inform(' Index must be rebuilt before database can be sorted. ')
  67. else do
  68.    call interactive(0)
  69.    call sortlist(ndx, db)
  70.    call setborder(ndx, 1)
  71.    call listscroll(objectnumber(db,1))
  72.    end
  73. F6_Sort by last names
  74. /* Extract last name field from 'Database' list to 'LastName Index' list */
  75. db  = 'Database'()
  76. ndx = 'LastName Index'()
  77. call beginprompt('Building index of last names. Please wait...')
  78. call interactive(0)
  79. call clearlist(ndx)
  80. do i = 1 to numelements(db)
  81.    it = objectnumber(db,i)
  82.    tx = getitemtext(it)
  83.    parse var tx . last ';'
  84.    call appenditem(ndx, strip(last,'b'), getitemcolor(it))
  85.    end
  86. F7_Build last name index
  87. /* Convert Database to mail merge file in TransWrite format. */
  88. db = 'Database'()
  89. if db = '' then EXIT
  90. n = numelements(db)
  91. if n = 0 then EXIT
  92. file = filerequest('Save data as mail merge file','ram:data.mm')
  93. if length(file) = 0 then EXIT
  94. if open(mm, file, 'Write') = 0 then do
  95.    say 'Unable to open file'
  96.    EXIT
  97.    end
  98. call beginprompt('Writing mail merge file...')
  99. do i = 1 to n
  100.    tx = getitemtext(objectnumber(db,i))
  101.    parse var tx name ';' street ';' city ';' state ';'
  102.    call writeln(mm, strip(name  ,'b'))
  103.    call writeln(mm, strip(street,'b'))
  104.    call writeln(mm, strip(city,  'b'))
  105.    call writeln(mm, strip(state, 'b'))
  106.    call writeln(mm, '>')
  107.    end
  108. call close(db)
  109. call endprompt()
  110. Save mail merge
  111. it = initiator()
  112. if length(it) == 0 then EXIT
  113. if gettype(it) ~= 'Item' then EXIT
  114. call inform('format record'(getitemtext(it)))
  115. Display record
  116. it = initiator()
  117. ndx = 'Lastname index'()
  118. db = 'database'()
  119. if getwidth(db) < 320 then do
  120.    call 'display record'()
  121.    exit
  122.    end
  123. oldtx = getitemtext(it)
  124. parse var oldtx oldfullname ';'
  125. oldname = word(oldfullname, words(oldfullname))
  126. itx = searchitems(ndx, oldname)
  127. tx = inputform('Edit record',setupform(oldtx))
  128. if tx = '' then EXIT
  129. parse var tx name '0a'X street '0a'X city '0a'X state '0a'X phone
  130. if name = '' then
  131.    name = oldfullname
  132. newname = word(name, words(name))
  133. if length(name)   < 21 then name   = left(name,  21)
  134. if length(street) < 26 then street = left(street,26)
  135. if length(city)   < 14 then city   = left(city,  14)
  136. if length(state)  < 14 then state  = left(state, 14)
  137. name   = name   || ';'
  138. street = street || ';'
  139. city   = city   || ';'
  140. state  = state  || ';'
  141. call interactive(0)
  142. call setitemtext(it, name || street || city || state || phone)
  143. call setitemtext(itx,newname)
  144. if getborder(ndx) then
  145.    call sortlist(ndx,db)
  146.    call sortlist(db,ndx)
  147.     EditEntry
  148. db = 'Database'()
  149. ndx = 'Lastname index'()
  150. tx = inputform('Add record',setupform(''))
  151. if tx = '' then EXIT
  152. parse var tx name '0a'X street '0a'X city '0a'X state '0a'X phone
  153. if length(name)   < 21 then name2  = left(name,  21)
  154. if length(street) < 26 then street = left(street,26)
  155. if length(city)   < 14 then city   = left(city,  14)
  156. if length(state)  < 14 then state  = left(state, 14)
  157. name2  = name2  || ';'
  158. street = street || ';'
  159. city   = city   || ';'
  160. state  = state  || ';'
  161. call interactive(0)
  162. it = appenditem(db, name2 || street || city || state || phone, 1)
  163. call setactionmacro(it,'EditEntry')
  164. call appenditem(ndx, word(name, words(name)), 1)
  165. if getborder(ndx) then
  166.    call sortlist(ndx,db)
  167.    call sortlist(db,ndx)
  168. AddEntry
  169. w/* This macro is designed to be called as a function by other macros in
  170.    the database. It formats a given record into a multi-line string in a
  171.    standard format.
  172. cr = '0a'X
  173. sp = '   '
  174. if arg() == 1 then do
  175.    tx = arg(1)
  176.    parse var tx name ';' street ';' city ';' state ';' phone
  177.    return cr ' ' name cr cr sp street cr sp city cr sp state cr sp phone cr
  178.    end
  179. Format record(rec)
  180. /* movenote - moves the large documentation note to given X position */
  181. call setposition(docnote,arg(1),getobjecttop('Docs'()))
  182. movenote(leftpos)
  183. /* switch to EDIT or BROWSE mode, and handle the ADD button */
  184. db      = 'database'()
  185. docnote = 'Docs'()
  186. n       = 'Edit button'()
  187. /* EDIT mode - move note offscreen, shrink list */
  188. if arg(1) == 'EDIT' then do
  189.    call setposition(docnote,640,gettop(docnote))
  190.    call scaletosize(db,640,getheight(db))
  191.    call replacetext(n,'ADD ',0,4)
  192.    call setactionrexx(n,"call editbrowse('ADD')")
  193.    end
  194. else if arg(1) == 'BROWSE' then do
  195.    call scaletosize(db,200,getheight(db))
  196.    call setposition(docnote,211,gettop(docnote))
  197.    call replacetext(n,'EDIT',0,4)
  198.    call setactionrexx(n,"call editbrowse('EDIT')")
  199.    end
  200. else if arg(1) == 'ADD' then do
  201.    call addentry()
  202.    end
  203. editbrowse(EDIT/BROWSE/ADD)
  204. D/* This macro is designed to be called as a function by other macros in
  205.    the database. It formats a given record into a multi-line string in a
  206.    standard format.
  207. cr = '0a'X
  208. if arg() == 1 then do
  209.    tx = arg(1)
  210.    parse var tx name ';' street ';' city ';' state ';' phone
  211.    name   = 'Name:'   || strip(name,  'b') || cr
  212.    street = 'Street:' || strip(street,'b') || cr
  213.    city   = 'City:'   || strip(city,  'b') || cr
  214.    state  = 'State:'  || strip(state, 'b') || cr
  215.    phone  = 'Phone:'  || strip(phone, 'b')
  216.    return name || street || city || state || phone
  217.    end
  218. SetUpForm(rec)
  219. "Database"
  220. ]Hugo Allbright       ;155 Cyclopean Terrace     ;Outright      ;WI 73348      ;(209) 789-7809
  221. ]Fortescue Barrymore  ;228 Rather Twisty Rd.     ;Lost Cause    ;CA 77332      ;(277) 332-7733
  222. ]Cynthia Botch        ;8345 Allopathy Ave.       ;Underfoot     ;CT 31855      ;(240) 402-7771
  223. ]Merton Canterbury    ;334 Prodigious Dr.        ;Plywood       ;PA 29748      ;(975) 975-9759
  224. ]Ida Caprice          ;4096 Redoubtable Cr.      ;Rabelais      ;BC Q3R 4S5    ;(774) 447-7474
  225. ]Gawain Cassowary     ;292 Average St. Unit 0    ;Plasma        ;ON U1V 2W3    ;(842) 842-8421
  226. ]Una Directrix        ;PO Box 888                ;W. Incentive  ;SC 13192      ;(456) 234-0123
  227. ]Penny Dropper        ;919 Flitch Road           ;Ignominy      ;CA 81393      ;(294) 121-8765
  228. ]Eleanor Entwhistle   ;525 E. 104th, Suite 106   ;Imprimatur    ;CA 50505      ;(123) 263-1919
  229. ]Abner Foo            ;PO Box 8411               ;Aspersion     ;CA 88227      ;(788) 228-8227
  230. ]Virginia Forest      ;1889 Voluntary Ave.       ;Mesmer Bluffs ;CA 86644      ;(866) 448-6644
  231. ]Ragnar Forkbeard     ;555 Dramaphone Road       ;Plugged Inlet ;BC C8D 8E8    ;(464) 646-4466
  232. ]Marigold Halflock    ;1828 Centurion Row        ;Anaconda      ;ON D6E 7F9    ;(424) 387-6914
  233. gEdwin LeBlanc        ;2055 W. Felicity St.      ;Chipmunk      ;CO 44019      ;(882) 303-0303  303-0305
  234. ]Livilla Long         ;922138 Short St.          ;Cherry Cluster;BC M5N 6P7    ;(123) 456-7890
  235. ]Reggie Mentation     ;8181 Arcturus Orbit       ;Plainsong     ;MA 87325      ;(765) 567-1829
  236. ]Clancy Overflow      ;314 Pi Lane               ;Approximation ;CA 44887      ;(744) 887-7448
  237. ZZizi Parcheesi       ;88 Overthrow Row          ;Strep         ;NC 55991      ;(155) 99115
  238. ]Jayne Payne-McBain   ;24 Beerbox Retreat        ;Deliquescence ;CA 66339      ;(966) 339-9663
  239. ]Andy Phlogiston      ;PO Box 1829               ;Atavism       ;NY 10699      ;(222) 222-3222
  240. ]Cerise Pillpot       ;#833 1024 256 St.         ;Cerumen       ;AB C2E 1D8    ;(303) 987-2345
  241. ]Arturo Pismire       ;Suite 39 1D Poirot Blvd.  ;Lipid City    ;CA 42929      ;(512) 812-1112
  242. ]Desiree Proust       ;8 Solidarity St.          ;Retrospect    ;WI 32158      ;(979) 797-9779
  243. ]Consuela Revelstoke  ;9942 Empyrean St.         ;Desuetude     ;TX 40104      ;(114) 341-8181
  244. ]Ellery Snide         ;1 Abernathy Road          ;Torpor        ;ON R7S 8T9    ;(393) 226-5044
  245. ]Claire Spritzer      ;66 Egregious Ave.         ;Canthrip      ;PA 75291      ;(765) 123-9191
  246. ]Irving Swirving      ;PO Box 811                ;Marjoram      ;MA 75316      ;(999) 888-7777
  247. ]Belinda Trestle      ;Apt. Q 8 Resplendency St. ;Cornucopia    ;ON D1H 3P1    ;(672) 395-1975
  248. ]Henry V. Fifth       ;7384 Bolingbroke Court    ;Agincourt     ;BC D9E 1F2    ;(486) 486-5975
  249. ]Simon Venables       ;1204 Principal Ave.       ;Bigtown       ;CO 71028      ;(392) 331-4848
  250. ]Yuri Venturi         ;PO Box 4949               ;Horners Corner;KA 97362      ;(833) 338-1234
  251. "LastName Index"
  252.     Allbright
  253.     Barrymore
  254. Botch
  255. Canterbury
  256. Caprice
  257.     Cassowary
  258.     Directrix
  259. Dropper
  260. Entwhistle
  261. Forest
  262.     Forkbeard
  263. Halflock
  264. LeBlanc
  265.     Mentation
  266. Overflow
  267.     Parcheesi
  268. Payne-McBain
  269. Phlogiston
  270. Pillpot
  271. Pismire
  272. Proust
  273. Revelstoke
  274. Snide
  275. Spritzer
  276. Swirving
  277. Trestle
  278. V. Fifth
  279. Venables
  280. Venturi
  281. "Docs"
  282. The Address Book D
  283. abase
  284. This simple but serviceable address book uses
  285. macros to automate its database functions. Click on
  286. a list item to see the full information for that
  287. entry. EDIT expands the list to full width so that
  288. you can edit the data (click on an entry to edit
  289. it). BROWSE switches back to the smaller size
  290. showing the names only. After adding or changing
  291. names, click on "Build index" to remake the special
  292. index Lists for the sort operations. The other
  293. buttons are self-explanatory - experiment! You can
  294. use Right-Amiga plus the indicated function keys
  295. instead of the buttons if you prefer.
  296. Group1
  297. Button1
  298. First name sort (F5)
  299. Button2
  300. Last name sort (F6)
  301. Button3
  302. Build index (F7)
  303. "Edit button"
  304. call editbrowse('ADD')
  305. ADD  
  306. "Browse button"
  307. call editbrowse('BROWSE')
  308. BROWSE 
  309. Button6
  310. SEARCH 
  311. Button7
  312. DELETE 
  313. "Contacts"
  314. diamond.font
  315.