home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CP/M
/
CPM_CDROM.iso
/
mbug
/
mbug054.arc
/
ADDR1.DOC
< prev
next >
Wrap
Text File
|
1979-12-31
|
12KB
|
462 lines
8 '
==================================
=== Written & Copyright (c) by ===
=== John Dowdall ===
9 ' OK TO COPY FOR INDIVIDUAL ===
=== USE ONLY.COMMERCIAL RIGHTS ===
=== RESERVED BY MICROFLEX ===
==================================
10 ' here we CLEAR memory and set both screen & printer widths
12 ' this USER-DEFINED function allows screen addressing
14 ' set the screen clear and some other variables
16 ' get the drive info
18 ' convert drive name to UPPER-CASE and re-check
20 ' set record length, check file, if none then initialise in 700-
22 ' otherwise get some details out of the file
24 ' set some control-key variables
26 '
28 '
30 '
32 '
34 '
36 '
38 ' set the error handler
40 ' ok now to start the actual program - so go do it !
100 REM ------------------------DISK FILE HANDLING-------------------------
102 ' open the files with specific record lengths
104 ' length of 2 means this is an INDEX file. kp% is No. of records in file
106 '
108 '
110 '
112 ' FIELD the data file record into record variables (all strings!)
114 '
116 ' copy file variables into memory variables (or 'work-variables')
118 '
120 ' set record data back into the fields to write to disk (with PUT)
122 '
124 REM
126 '
128 ' get a record (number PR%) from disk
130 '
132 ' PUT a record onto disk in position number PR%
134 '
136 ' clear work variables
138 ' get header data from file
140 ' put header data onto disk
142 '
144 ' FIELD the second INDEX
146 '
148 '
150 '
152 '
154 ' a time waster loop
200 REM --------------------KEYBOARD ENTRY ROUTINE----------------------------
202 ' clear the inkey$ variable ready for use
204 ' check inkey$. if null then try again - else->
206 ' if not null check for KEY TOGGLE (@) or backspace (DEL)
208 ' check for print labels switch (CTRL-L)
210 ' check for screen-print switch
212 ' check for <RETURN> key and CTRL-keys
214 ' check for backspace, handle as destructive (DEL)
216 ' build input string and go back for next character
218 ' toggle PRIN% to 0 or -1 for 'screen dump' routine
220 '
222 '
224 '
226 ' GOTO 202
300 REM ---------------------MAIN DATA-ENTRY SCREEN---------------------------
302 ' set up initial data-entry screen
304 ' set prompt variables
306 ' go to get key field (either NAME or CATEGORY) depending on
value of variable TOGGLE
308 ' check for EDIT
and for DELETE calls and handle them if so
310 ' check for REINDEX
and for SORT calls and handle if so
312 ' check for forward or backward movement calls
and handle if needed
314 ' more browsing movement checks
316 ' if the record exists,display it & set display flag, or its a new one
318 ' so set some variables
320 ' and get the address line (street)
322 ' and the city. If CTRL-K pressed then clear windows and start again
324 ' get the postcode
326 ' get the phone
328 ' get the category
330 ' store the new record onto the disk
332 '
334 ' GOTO 302
400 REM --------------------------EDITING-------------------------------------
402 ' place field numbers beside data
404 ' prompt for field number
406 ' make sure its not too big
408 ' clear last two lines ready for prompt
410 ' this is a 'hidden' function (for programmer, NOT operator!)
412 ' get new street
414 ' get new city
416 ' get new postcode
418 ' get new phone
420 ' get new category
422 ' GOTO 404
424 ' clear editing prompts and return to normal screen
450 REM ---------------------------DELETE-------------------------------------
452 ' you're going to DELETE the displayed record
454 ' so do it !
456 '
458 ' check for previously deleted
460 '
462 '
464 '
500 REM ---------------------------SORT---------------------------------------
502 ' re-FIELD the file to one long string & set some variables
504 ' this is a SCHELL-METZNER sort so its 'divide (by 2) and conquor'
506 '
508 ' when M=0 then job's done
510 '
512 '
514 '
516 ' get the two records for compare. if deleted then sort 'em to
518 ' the BOTTOM of the list ready for final oblivion
520 ' and put 'em away
522 ' else check if <= ... and skip if so
524 ' otherwise, swap 'em
526 '
528 '
530 '
532 '
534 '
536 '
538 '
540 ' heres where tose deleted records finally get lost
542 '
544 '
546 ' 25 beeps at rapid-fire rate then go RE-INDEX
600 REM ----------------------------REKEY INDEX-------------------------------
602 ' re-FIELD to normal
604 '
606 ' null out the main (NAME) index
608 ' get the record
610 ' HASH the key field (NAME) for index position
612 ' check that the position is unused
614 ' if it was deleted then mark it negative else positive
616 ' if it was in use, get the next one
618 ' put it away
620 ' next record until done, then do the CATEGORY INDEX
622 '
624 '
650 REM -----------REKEY CATEGORY INDEX----------
652 ' exactly the same procedure as for NAME INDEX
654 '
656 '
658 '
660 '
662 '
664 '
666 '
668 '
670 '
700 REM ----------------------INITIALISE NEW FILE-----------------------------
702 ' screen header
704 ' get company name for file header
but re-RUN if its an asterisk
706 ' get address
708 ' some redundant code here
710 '
712 '
714 '
716 '
718 ' get paper lngth
720 ' set maximum number of records for a single disk
722 '
724 ' make sure its all OK
726 ' but if not go get it all again
728 ' put it away if OK
730 '
732 '
734 '
736 '
738 '
740 ' and re-RUN from the start
798 REM =======================GENERAL SUB-ROUTINES===========================
800 REM -------------------------PROGRAM EXIT SCREEN--------------------------
802 ' this is where files are closed and program ends
900 REM ------------------------KEYBOARD INPUT OF KEY-------------------------
902 ' set up screen
904 ' get input and check for EXIT or ? or TOGGLE (@)
906 ' if its a valid record number then get it
908 ' if its a CTRL-key then go back to handle it
910 ' if its a name then get HASH and check if OK
912 ' get the indicated record & check
914 ' check for match set p1=0 if not
916 ' and try again if no match, else skip if deleted
918 ' back to display if a valid record
920 ' or to get new data if 'NOT FOUND'
922 '
924 ' move the record pointer if a movement is requested with CTRL-key
926 '
928 ' make sure pointer is in range
930 ' get the record
932 '
934 '
936 '
938 ' update the category index
940 '
942 '
944 '
1000 REM -------------------------PRINT '?' LISTING---------------------------
1002 ' this routine responds if the operator command is '?'
1004 '
1006 '
1008 '
1100 REM -----------------------------HASHING ALGORITHM-----------------------
1102 ' calculate HASH number
1104 ' using ASCII values of all the letters in the name
1106 '
1108 ' make sure its big enough
1110 ' calculate position & get the number (its sort of random-ish!)
1112 ' get it into range & return
1150 REM -------------------CATEGORY HASH-----------------
1152 ' same as above except for category
1154 '
1156 '
1158 '
1160 '
1162 '
1200 REM -------------------------DATE CHECKING & CONVERSION-------------------
1202 ' accept any separator for date (in DD/MM/YY format)
and change back to '/'
1204 ' now check for DD/MM/YY or D/M/YY or DD/M/YY or D/MM/YY etc
1206 '
1208 '
1210 ' if it ain't the right size after all that then its an error!
1212 ' now check number of days in the month and handle if
in error
1214 '
1216 ' set the error flag to 0 if no errors
1218 ' or to 1 if its wrong
1220 ' now compress the date to 4 characters for disk storage
1222 '
1224 ' this bit DE-compresses the disk form into DD/MM/YY
1226 '
1228 '
1300 REM --------------------------SCREEN HEADER-----------------------------
1302 ' clear the screen & put the heading on
1304 ' set the screen dump flag on the screen if set
1306 ' and return
1400 REM -----------------------PRESS <RETURN> PROMPTS----------------------
1402 ' printing routine required
1404 ' if it's labels, then see if only a count required
1406 '
1408 ' some more printer prompts
1410 '
1412 '
1414 '
1416 '
1418 '
1420 ' screen set-up for 900 and 1800 routines
1422 '
1424 '
1500 REM -------------------DATA ENTRY WINDOWS-------------------------------
1502 ' set out the data-entry windows
1504 '
1506 '
1508 '
1510 '
1512 '
1514 '
1516 ' put bottom lines on screen
1518 '
1600 REM -------------------FILL WINDOWS AFTER 'FIND'-------------------------
1602 ' fill the windows with the 'FOUND' record
1604 ' and print it if needed
1606 '
1700 REM -----------------------------ERROR TRAP------------------------------
1702 ' display error message
1704 '
1706 '
1800 REM -------------------------get record by category----------------------
1802 ' this routine is the same
1804 ' as the one in the 900's
1806 '
1808 '
1810 '
1812 '
1814 '
1816 '
1818 '
1820 '
1822 '
1824 '
1826 '
1900 REM ---------------------------IS THIS THE ONE ??-----------------------
1902 ' is this the one yoyu wanted???
1904 ' clear the line
1906 '
2000 REM ---------------------------ADJUST TOGGLE FOR KEY FIELD--------------
2002 IF TOGGLE IS 0 THEN GET NAME ELSE GET CATEGORY
2004 '
2100 REM ........................PRINT LABELS..................................
2102 ' get & check options
2104 ' and act on 'em
2106 ' this one is for printed address labels
2108 ' so do them
2110 ' but skip if deleted
2112 ' and skip if the CATEGORY doesn't match
2114 ' else print
2116 '
2118 '
2150 REM ----------------------COUNT FOR CATEGORY SELECTED------------------
2152 ' this option is for just counting
2154 ' but otherwise its the same as printing
2156 '
2158 '
2160 '
2162 '
2164 ' display count
2166 '
2168 ' and return
2200 REM .......................PRINT 'BOOK'...................................
2202 ' this is the address book - 20 addresses to the page
2204 ' print the heading
2206 ' start the record count
2208 ' print them all if not deleted
2210 ' this method allows blanks in second column if not enough addresses
2212 '
2214 '
2216 '
2218 '
2220 '
2222 '
2224 '
2226 ' form feed
2300 REM .................DETERMINE STATE FROM POSTCODE........................
2302 ' AUST POST lays em out like this
2304 '
2306 '
2308 '
2310 '
2312 '
2314 '
2316 '
2318 '
2400 REM ....................CHECK CATEGORY FOR MATCH..........................
2402 ' the '~' is an anything character
2404 '
2406 '
2408 '
2410 '
2412 '
2414 '
2416 '
2500 REM ....................GET CATEGORY FOR LABELS...........................
2502 ' get the category required...use '~' for 'don't care'
2504 '
2506 '
2508 ' check for valid characters
2510 '
2512 '
2600 REM ..........................GET SORT FIELD..............................
2602 ' which field to sort on???
2604 ' check for valid field
2606 ' set the field positions
2608 '
2700 REM ......................PART OF CATEGORY CHECK..........................
2702 ' these check for special vaalues in the category fields
2704 ' for further details, see the README file
2706 '
2708 '
2710 '
2712 '
2714 '
2716 '
2718 '
2720 '
2722 '
2724 '
2726 '
2728 '
2730 '
2732 '
2800 REM ........................PRINT COPY OF WINDOW..........................
2802 ' this is the pseudo screen dump routine
2804 '
2806 '
2808 '
........PRINT COPY OF WINDOW..........................
2802 ' this is the pseudo screen dump routine
2804 '
2806 '
28