home *** CD-ROM | disk | FTP | other *** search
HyperBook | 1990-10-07 | 15.8 KB | 315 lines |
- e/* F1_Edit or Add - This exists only to implement the F1 shortcut */
- call activate('Edit button'())
- F1_Edit or Add
- d/* F2_Browse - This exists solely to implement the F2 shortcut */
- call activate('Browse button'())
- F2_Browse
- %db = 'Database'()
- if numelements(db) = 0 then EXIT
- text = inputstring('Enter search text', '')
- if text = '' then EXIT
- it = objectnumber(db,1)
- cr = '0a'X
- do forever
- it = searchitems(it, text)
- if it = '' then do
- call inform(cr || 'Not found' || cr)
- EXIT
- end
- output = 'Format record'(getitemtext(it)) cr 'Search again?' cr
- if getresponse(output) then do
- it = getnext(it)
- if it = '' then do
- call inform(cr || 'Not found' || cr)
- EXIT
- end
- end
- else
- EXIT
- end
- F3_Search for item
- db = 'Database'()
- ndx = 'Lastname index'()
- if numelements(db) = 0 then EXIT
- it = selectitem(db, 'Select a record to delete')
- tx = getitemtext(it)
- cr = '0a'X
- output = 'Format record'(tx) cr 'Really delete this record?' cr
- if getresponse(output) then do
- call delete(it)
- parse var tx name ';'
- name = trim(name)
- name = word(name, words(name))
- it = searchitems(ndx, name)
- if it = '' then EXIT
- if abbrev(getitemtext(it), name) then
- call delete(it)
- end
- F4_Delete record
- /* Sort 'Database' list and, subordinately, the 'LastName Index' list (if
- it exists).
- db = 'Database'()
- ndx = 'LastName Index'()
- if numelements(db) ~= numelements(ndx) then
- call inform(' Index must be rebuilt before database can be sorted. ')
- else do
- call interactive(0)
- call sortlist(db, ndx)
- call setborder(ndx,0)
- call listscroll(objectnumber(db,1))
- end
- F5_Sort by first names
- l/* Sort 'Database' list subordinate to sorting 'LastName Index' list */
- db = 'Database'()
- ndx = 'LastName Index'()
- if numelements(ndx) ~= numelements(db) then
- call inform(' Index must be rebuilt before database can be sorted. ')
- else do
- call interactive(0)
- call sortlist(ndx, db)
- call setborder(ndx, 1)
- call listscroll(objectnumber(db,1))
- end
- F6_Sort by last names
- /* Extract last name field from 'Database' list to 'LastName Index' list */
- db = 'Database'()
- ndx = 'LastName Index'()
- call beginprompt('Building index of last names. Please wait...')
- call interactive(0)
- call clearlist(ndx)
- do i = 1 to numelements(db)
- it = objectnumber(db,i)
- tx = getitemtext(it)
- parse var tx . last ';'
- call appenditem(ndx, strip(last,'b'), getitemcolor(it))
- end
- F7_Build last name index
- /* Convert Database to mail merge file in TransWrite format. */
- db = 'Database'()
- if db = '' then EXIT
- n = numelements(db)
- if n = 0 then EXIT
- file = filerequest('Save data as mail merge file','ram:data.mm')
- if length(file) = 0 then EXIT
- if open(mm, file, 'Write') = 0 then do
- say 'Unable to open file'
- EXIT
- end
- call beginprompt('Writing mail merge file...')
- do i = 1 to n
- tx = getitemtext(objectnumber(db,i))
- parse var tx name ';' street ';' city ';' state ';'
- call writeln(mm, strip(name ,'b'))
- call writeln(mm, strip(street,'b'))
- call writeln(mm, strip(city, 'b'))
- call writeln(mm, strip(state, 'b'))
- call writeln(mm, '>')
- end
- call close(db)
- call endprompt()
- Save mail merge
- it = initiator()
- if length(it) == 0 then EXIT
- if gettype(it) ~= 'Item' then EXIT
- call inform('format record'(getitemtext(it)))
- Display record
- it = initiator()
- ndx = 'Lastname index'()
- db = 'database'()
- if getwidth(db) < 320 then do
- call 'display record'()
- exit
- end
- oldtx = getitemtext(it)
- parse var oldtx oldfullname ';'
- oldname = word(oldfullname, words(oldfullname))
- itx = searchitems(ndx, oldname)
- tx = inputform('Edit record',setupform(oldtx))
- if tx = '' then EXIT
- parse var tx name '0a'X street '0a'X city '0a'X state '0a'X phone
- if name = '' then
- name = oldfullname
- newname = word(name, words(name))
- if length(name) < 21 then name = left(name, 21)
- if length(street) < 26 then street = left(street,26)
- if length(city) < 14 then city = left(city, 14)
- if length(state) < 14 then state = left(state, 14)
- name = name || ';'
- street = street || ';'
- city = city || ';'
- state = state || ';'
- call interactive(0)
- call setitemtext(it, name || street || city || state || phone)
- call setitemtext(itx,newname)
- if getborder(ndx) then
- call sortlist(ndx,db)
- call sortlist(db,ndx)
- EditEntry
- db = 'Database'()
- ndx = 'Lastname index'()
- tx = inputform('Add record',setupform(''))
- if tx = '' then EXIT
- parse var tx name '0a'X street '0a'X city '0a'X state '0a'X phone
- if length(name) < 21 then name2 = left(name, 21)
- if length(street) < 26 then street = left(street,26)
- if length(city) < 14 then city = left(city, 14)
- if length(state) < 14 then state = left(state, 14)
- name2 = name2 || ';'
- street = street || ';'
- city = city || ';'
- state = state || ';'
- call interactive(0)
- it = appenditem(db, name2 || street || city || state || phone, 1)
- call setactionmacro(it,'EditEntry')
- call appenditem(ndx, word(name, words(name)), 1)
- if getborder(ndx) then
- call sortlist(ndx,db)
- call sortlist(db,ndx)
- AddEntry
- w/* This macro is designed to be called as a function by other macros in
- the database. It formats a given record into a multi-line string in a
- standard format.
- cr = '0a'X
- sp = ' '
- if arg() == 1 then do
- tx = arg(1)
- parse var tx name ';' street ';' city ';' state ';' phone
- return cr ' ' name cr cr sp street cr sp city cr sp state cr sp phone cr
- end
- Format record(rec)
- /* movenote - moves the large documentation note to given X position */
- call setposition(docnote,arg(1),getobjecttop('Docs'()))
- movenote(leftpos)
- /* switch to EDIT or BROWSE mode, and handle the ADD button */
- db = 'database'()
- docnote = 'Docs'()
- n = 'Edit button'()
- /* EDIT mode - move note offscreen, shrink list */
- if arg(1) == 'EDIT' then do
- call setposition(docnote,640,gettop(docnote))
- call scaletosize(db,640,getheight(db))
- call replacetext(n,'ADD ',0,4)
- call setactionrexx(n,"call editbrowse('ADD')")
- end
- else if arg(1) == 'BROWSE' then do
- call scaletosize(db,200,getheight(db))
- call setposition(docnote,211,gettop(docnote))
- call replacetext(n,'EDIT',0,4)
- call setactionrexx(n,"call editbrowse('EDIT')")
- end
- else if arg(1) == 'ADD' then do
- call addentry()
- end
- editbrowse(EDIT/BROWSE/ADD)
- D/* This macro is designed to be called as a function by other macros in
- the database. It formats a given record into a multi-line string in a
- standard format.
- cr = '0a'X
- if arg() == 1 then do
- tx = arg(1)
- parse var tx name ';' street ';' city ';' state ';' phone
- name = 'Name:' || strip(name, 'b') || cr
- street = 'Street:' || strip(street,'b') || cr
- city = 'City:' || strip(city, 'b') || cr
- state = 'State:' || strip(state, 'b') || cr
- phone = 'Phone:' || strip(phone, 'b')
- return name || street || city || state || phone
- end
- SetUpForm(rec)
- "Database"
- ]Hugo Allbright ;155 Cyclopean Terrace ;Outright ;WI 73348 ;(209) 789-7809
- ]Fortescue Barrymore ;228 Rather Twisty Rd. ;Lost Cause ;CA 77332 ;(277) 332-7733
- ]Cynthia Botch ;8345 Allopathy Ave. ;Underfoot ;CT 31855 ;(240) 402-7771
- ]Merton Canterbury ;334 Prodigious Dr. ;Plywood ;PA 29748 ;(975) 975-9759
- ]Ida Caprice ;4096 Redoubtable Cr. ;Rabelais ;BC Q3R 4S5 ;(774) 447-7474
- ]Gawain Cassowary ;292 Average St. Unit 0 ;Plasma ;ON U1V 2W3 ;(842) 842-8421
- ]Una Directrix ;PO Box 888 ;W. Incentive ;SC 13192 ;(456) 234-0123
- ]Penny Dropper ;919 Flitch Road ;Ignominy ;CA 81393 ;(294) 121-8765
- ]Eleanor Entwhistle ;525 E. 104th, Suite 106 ;Imprimatur ;CA 50505 ;(123) 263-1919
- ]Abner Foo ;PO Box 8411 ;Aspersion ;CA 88227 ;(788) 228-8227
- ]Virginia Forest ;1889 Voluntary Ave. ;Mesmer Bluffs ;CA 86644 ;(866) 448-6644
- ]Ragnar Forkbeard ;555 Dramaphone Road ;Plugged Inlet ;BC C8D 8E8 ;(464) 646-4466
- ]Marigold Halflock ;1828 Centurion Row ;Anaconda ;ON D6E 7F9 ;(424) 387-6914
- gEdwin LeBlanc ;2055 W. Felicity St. ;Chipmunk ;CO 44019 ;(882) 303-0303 303-0305
- ]Livilla Long ;922138 Short St. ;Cherry Cluster;BC M5N 6P7 ;(123) 456-7890
- ]Reggie Mentation ;8181 Arcturus Orbit ;Plainsong ;MA 87325 ;(765) 567-1829
- ]Clancy Overflow ;314 Pi Lane ;Approximation ;CA 44887 ;(744) 887-7448
- ZZizi Parcheesi ;88 Overthrow Row ;Strep ;NC 55991 ;(155) 99115
- ]Jayne Payne-McBain ;24 Beerbox Retreat ;Deliquescence ;CA 66339 ;(966) 339-9663
- ]Andy Phlogiston ;PO Box 1829 ;Atavism ;NY 10699 ;(222) 222-3222
- ]Cerise Pillpot ;#833 1024 256 St. ;Cerumen ;AB C2E 1D8 ;(303) 987-2345
- ]Arturo Pismire ;Suite 39 1D Poirot Blvd. ;Lipid City ;CA 42929 ;(512) 812-1112
- ]Desiree Proust ;8 Solidarity St. ;Retrospect ;WI 32158 ;(979) 797-9779
- ]Consuela Revelstoke ;9942 Empyrean St. ;Desuetude ;TX 40104 ;(114) 341-8181
- ]Ellery Snide ;1 Abernathy Road ;Torpor ;ON R7S 8T9 ;(393) 226-5044
- ]Claire Spritzer ;66 Egregious Ave. ;Canthrip ;PA 75291 ;(765) 123-9191
- ]Irving Swirving ;PO Box 811 ;Marjoram ;MA 75316 ;(999) 888-7777
- ]Belinda Trestle ;Apt. Q 8 Resplendency St. ;Cornucopia ;ON D1H 3P1 ;(672) 395-1975
- ]Henry V. Fifth ;7384 Bolingbroke Court ;Agincourt ;BC D9E 1F2 ;(486) 486-5975
- ]Simon Venables ;1204 Principal Ave. ;Bigtown ;CO 71028 ;(392) 331-4848
- ]Yuri Venturi ;PO Box 4949 ;Horners Corner;KA 97362 ;(833) 338-1234
- "LastName Index"
- Allbright
- Barrymore
- Botch
- Canterbury
- Caprice
- Cassowary
- Directrix
- Dropper
- Entwhistle
- Forest
- Forkbeard
- Halflock
- LeBlanc
- Mentation
- Overflow
- Parcheesi
- Payne-McBain
- Phlogiston
- Pillpot
- Pismire
- Proust
- Revelstoke
- Snide
- Spritzer
- Swirving
- Trestle
- V. Fifth
- Venables
- Venturi
- "Docs"
- The Address Book D
- abase
- This simple but serviceable address book uses
- macros to automate its database functions. Click on
- a list item to see the full information for that
- entry. EDIT expands the list to full width so that
- you can edit the data (click on an entry to edit
- it). BROWSE switches back to the smaller size
- showing the names only. After adding or changing
- names, click on "Build index" to remake the special
- index Lists for the sort operations. The other
- buttons are self-explanatory - experiment! You can
- use Right-Amiga plus the indicated function keys
- instead of the buttons if you prefer.
- Group1
- Button1
- First name sort (F5)
- Button2
- Last name sort (F6)
- Button3
- Build index (F7)
- "Edit button"
- call editbrowse('ADD')
- ADD
- "Browse button"
- call editbrowse('BROWSE')
- BROWSE
- Button6
- SEARCH
- Button7
- DELETE
- "Contacts"
- diamond.font
-