home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Overload
/
ShartewareOverload.cdr
/
database
/
nj_map.zip
/
NJMAP.PRG
next >
Wrap
Text File
|
1988-07-07
|
8KB
|
243 lines
* - BOF - *
*****
* This dBase (or Clipper) program will plot a New Jersey state
* "map" using your data base. The map will show where each of
* your records is located in the state. (A sample map is at the end of
* of this program.)
*
* We license ambulance services and related vehicles. I wrote this program
* because we needed to "see" where the services and vehicles were located;
* the resulting maps have become valuable tools.
*
* The program uses the grid system which appears on the "New Jersey
* State Map" distributed by the Division of Tourism.
*
* To use this program, you'll have to add the map grid, such as "B12,"
* to each record. I used two fields:
*
* map_ltr character SPACE(1)
* This field is for the letters (A thru W) which appear on each side
* of the state map.
*
* map_num character SPACE(2)
* This field is for the numbers (1 thru 13) which appear on the top and
* bottom of the state map. This program expects the map numbers to NOT
* have leading zeroes. (i.e. " 1" or " 2" is good; "01" or "02" is bad.)
*
* After you add the fields, you'll have to type-in the "grid code" for
* each record.
*
* If you need to plot a map, have a -=>LOT<=- of records (with zip codes)
* and you can't add fields, there are other approaches. Call me.
*
* Ron Hockemeier, 609-292-6789
* EMS Program, NJ Dept. of Health, CN 364, Trenton, NJ 08625-0364
*
*****
* Initialize the letters for the grid code.
* (The state map uses the letters A thru W.)
start_ltr=[A]
end_ltr=[W]
* Initialize the numbers for the grid code.
* (The state map uses the numbers 1 thru 13.)
start_num=1
end_num=13
* Initialize the variables to plot the map on the page.
line=1
start_lin=5
start_col=15
choice=[P53] && for demo only--should be passed from your calling program
* Initialize the "grand total counter."
tot_cnt=0
choice=[P53] && for demo only--should be passed from your calling program
* Initialize printer variables. (Usually in a separate program.)
* These are EPSON LQ 1000 instructions. They'll probably work with other
* EPSONS and compatibles.
elite=CHR(27)+[M] && epson 12 cpi
bold_on =CHR(27)+[E]+CHR(27)+[G]
bold_off=CHR(27)+[F]+CHR(27)+[H]
init_prnt=CHR(27)+[@]
tiny_on =CHR(15)
tiny_off=CHR(18)
* Index on the grid letters and numbers.
* USE <yourfile>
CLEA
@ 10,31 say [I'm getting ready.]
INDEX on UPPE(map_ltr)+map_num TO C:njmap
SET INDEX TO C:njmap
@ 10,31 say SPAC(30)
@ 10,28 say [I'm printing the "map."]
* Initialize the page header. "Choice" should be from your calling program
DO CASE
CASE SUBS(choice,1,3) $[P53]
page_hdg=[<Your First Heading> "Map"]
CASE SUBS(choice,1,3) $[P55]
page_hdg=[<Your Second Heading> "Map"]
ENDC
* Print the page header.
SET DEVI TO PRIN
@ line,0 SAY bold_on+[ ]+elite+[ ]
@ line+1,(98-LEN(page_hdg))/2 SAY page_hdg
* Print the map numbers at the top of the map.
work_num=start_num
DO WHIL work_num < (end_num+1)
col=start_col+(work_num*4)
@ line+3,COL SAY STR(work_num,4)
work_num=work_num+1
ENDD
SET DEVI TO SCREEN
* Start the outside loop.
* The outside loop goes thru the letters (A thru W) and "down" the page.
DO WHIL (start_ltr <= end_ltr)
* Calculate the line we'll print on during this pass thru the loop.
line=start_lin+((ASC(start_ltr)-64)*2)
* Print the map letter at the left margin.
SET DEVI TO PRIN
@ line,(start_col) SAY start_ltr
SET DEVI TO SCREEN
* Start the middle loop.
* The middle loop goes thru the numbers (1 thru 13) and "across" the page.)
work_num=start_num
DO WHIL (work_num <= end_num)
* Initialize "map_grid" for this pass thru the middle loop.
* Map_grid is a memory variable which represents each
* consecutive grid on the state map. It starts as "A 2." It ends
* as "W13."
map_grid=start_ltr+STR(work_num,2)
* See if there's something at this grid.
SEEK map_grid
IF found()
* There's something at this map grid.
* Initialize the counter for the inside loop.
map_cnt=0
* Start the inside loop.
* The inside loop moves thru each record which matches "map_grid."
DO WHIL map_grid=UPPE(map_ltr)+map_num .AND. .NOT. EOF()
* Increment the counters depending on the CASE STATEMENT.
* Count each record (by adding +1) or
* Add the value of the number field.
* ("Choice" should be from your calling program.)
DO CASE
CASE SUBS(choice,1,3) $[P53]
* We're counting the record
tot_cnt=tot_cnt+1
map_cnt=map_cnt+1
CASE SUBS(choice,1,3) $[P55]
* We're adding the value from your number field.
* tot_cnt=tot_cnt+<your number field>
* map_cnt=map_cnt+<your number field>
ENDC
SKIP
ENDDO WHIL map_grid=UPPE(map_ltr)+map_num .AND. .NOT. EOF()
* We're out of the inside loop.
* Since FOUND() was true; we know at least one record
* is at this grid.
* However, if we're adding the value for a number field,
* map_cnt might equal zero because the number field equals zero.
IF map_cnt>0
* Calculate the column which represents the map grid.
col=start_col+(work_num*4)-4
* Print the info out at the "correct spot" on the "map."
SET DEVI TO PRIN
@ line,COL SAY STR(map_cnt,4)
SET DEVI TO SCREEN
ENDIF map_cnt>0
ENDif found()
* Increase the variable for the next pass thru the middle loop.
work_num=work_num+1
ENDDO WHIL (work_num <= end_num)
* We're out of the middle loop. Print the map letter at the right margin.
SET DEVI TO PRIN
col=start_col+(end_num*4)+10
@ line,COL SAY start_ltr
SET DEVI TO SCREEN
* Initialize the variables for the next pass thru the middle loop.
work_num=start_num
start_ltr=CHR(ASC(start_ltr)+1)
ENDDO WHIL (start_ltr <= end_ltr)
* We're out of the outside loop. Print the map numbers at the bottom.
work_num=start_num
SET DEVI TO PRIN
DO WHIL work_num < (end_num+1)
col=start_col+(work_num*4)
@ line+2,COL SAY STR(work_num,4)
work_num=work_num+1
ENDD
* Initialize the footer messages.
foot_msg1=[The grid system on this "map" is based on the New ]+ ;
[Jersey State Map distributed by the Division of Tourism.]
foot_msg2=[This "map" shows the number of ]
DO CASE
CASE SUBS(choice,1,3) $[P53]
foot_msg2=foot_msg2+[<Your first message> in each grid.]
foot_msg3=[In total, ]+LTRIM(STR(tot_cnt,9))+ ;
[ <Your word> appear on this "map."]
CASE SUBS(choice,1,3) $[P55]
foot_msg2=foot_msg2+[<Your next message> in each grid.]
foot_msg3=[In total, ]+LTRIM(STR(tot_cnt,9))+ ;
[ <Your next word> appear on this "map."]
ENDC
* Mention the number of records--if any--which were weren't counted.
IF recc()>tot_cnt
foot_msg3=foot_msg3+[ (]+LTRIM(STR( (RECC()-tot_cnt),9))+ ;
[ records couldn't be counted.)]
ENDIF recc()>tot_cnt
foot_msg4=[<Your Office Name> -- Printed ]+DTOC(DATE())+[.]
* print the footers.
@ line+3,(start_col) SAY bold_off+tiny_on
@ line+4,20 SAY foot_msg1
@ line+5,20 SAY foot_msg2
@ line+6,20 SAY foot_msg3
@ line+7,20 SAY foot_msg4+tiny_off
EJEC
* Reset the printer
@ PROW(),1 SAY init_prnt+[ ]
SET DEVI TO SCREE
@ 10,27 say SPAC(40)
@ 10,33 say [I'm finished.]
RETU
* - EOF - *