woody@chinacat.Unicom.COM (Woody Baker @ Eagle Signal) (05/07/90)
Some time ago, I posted a note that I had a graphing program. This program takes data points and graphs them with diffrent line styles. It does NOT do directed graphs. Normaly, I program in 'C' and Postscript. But I have found that the combination of BASIC and Postscript is rather potent. I basicaly design and debug the postscript programs with hard coded data. Then I run a little program that creates a disk file that has a line number, and the word LPRINT " followed by a line of postscript text, and terminated by a " This routine reads the debugged Postscript code, and creates a simple program that when run from IBM basic, simply prints the code to the printer. Then I go into where the hard coded data is, and replace it with variables. After that I write BASIC code to fill out the variables and print the stuff to the printer. This is how my Bumpersticker program and Business card program, etc work. I find this easy, and very powerful. The results of a program run, is a unique Postscript program that goes to the printer. The following routine was written in order to do a presentation to a church business meeting for our church. IT was designed to show graphicly, the current financial state of the church at that time. It will have to be modified rather heavily to be of use, but it may be useful. 5 REM GOTO 410 100 DIM MON$(24):FOR I = 0 TO 23: READ MON$(I):NEXT I 110 DATA "Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec" 120 DATA "Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec","spar" 410 READ NL,XINC,YINC,PTSIZ,XDIV,YDIV:GOSUB 1000:GOSUB 4000:REM lay down the axis. 440 FOR I= 1 TO NL:GOSUB 500: NEXT I:GOSUB 15000:LPRINT"showpage";CHR$(4) 499 END 500 READ NUM,INC:IN=0:GOSUB 900:READ X,Y:Y=Y*YDIV:GOSUB 1100 510 READ A:IF A=-999 THEN 560 520 IN=IN+INC:X=IN:Y=A*YDIV:GOSUB 1200 540 GOTO 510 560 LPRINT"stroke ":RETURN 899 REM select correct line 900 ON NUM GOSUB 1300,1400,1500,1600,1700,1800,1900,2000:RETURN 1000 LPRINT"/Courier findfont";PTSIZ;" scalefont setfont" 1005 LPRINT "90 rotate 0 -612 translate 50 50 translate .01 setlinewidth ":RETURN 1100 LPRINT X,Y;"moveto ":RETURN 1200 LPRINT X,Y;" lineto ":RETURN 1300 LPRINT"[] 0 setdash":RETURN 1400 LPRINT"[3] 0 setdash":RETURN 1500 LPRINT"[2] 0 setdash":RETURN 1600 LPRINT"[2 1] 0 setdash":RETURN 1700 LPRINT "[1 2 1] 0 setdash":RETURN 1800 LPRINT"[2 3] 0 setdash":RETURN 1900 LPRINT"[3 1] 0 setdash":RETURN 2000 LPRINT"[4 1 1] 0 setdash":RETURN 4000 LPRINT"0 0 moveto 790 0 lineto stroke":REM base line 4010 LPRINT"0 0 moveto 0 512 lineto stroke":REM vertical line 4020 FOR I = 0 TO 512 STEP YINC:LPRINT "-5";I;" moveto 5";I;" lineto stroke" 4030 LPRINT 0-(PTSIZ*6);I-(PTSIZ/4);"moveto (";I/YDIV;") show" 4050 NEXT I:REM 6 above is number of digits max 4120 FOR I = 0 TO 792 STEP XINC:LPRINT I;"-5 moveto ";I;"5 lineto stroke" 4130 Z1=I/XDIV:M$=MON$(Z1):LPRINT I-(PTSIZ/4);-6;" moveto -90 rotate (";Z1;M$;") show 90 rotate" 4140 NEXT I 4999 RETURN 9000 REM each line consists of the following elements 9010 REM first is a line style number, next the horizontal increment 9020 REM next is the x and y coord of start of the line 9030 REM relative to 0, and the next points are the y values for each 9040 REM point on the line. The increment is governed by the inc 9050 REM parameter.The end of each data line is -999 but this can be 9060 REM changed at will. 9070 REM 9100 REM the x and y axis numbering increments are used to scale the 9200 REM data. For example, the xinc and yinc are used to space the 9250 REM coordinates on the graph. They are in points. The xinc 9260 REM gets set on a line by line basis, that is the evenly 9270 REM spaced x coordinates are computed in points. in the example 9280 REM the xcord is 35 points, or approx 1/2 inch. The verical increment 9290 REM is every 5 points. However, the vertical axis needs to represent 9300 REM 200 per increment, there fore the y numbering inrements needs to 9320 REM be divided by .25 (or multiplied by 4) to generate the labels for 9340 REM in this case, we want the xasis to be spaced every 1/2 inch 9350 REM and we don't want the xaxis labeld in points, rather we want 9360 RME IT LABELED FROM 0. THERE FOR IF WE DIVIDE THE VALUES BY 9370 REM 35 (remember in this example, each division is 35 points wide 9380 REM ) we get numbers 0-whatever. 9390 REM 9998 DATA 5,35,5,5:REN NUMBER OF LINES, XINC, Y INC FOR AXSIS COORDS,POINT SIZE 9999 DATA 35,.025: REM x and y axis numbering increments, (units divider) 10000 REM DATA 1,35,0,12,14,19,29,19,29,-999 10010 REM DATA 4,35,0,16,19,29,49,59,-999 10100 DATA 1,35,0,12847,11722,12140,12403,10959,14834,13474,14142,10433,7844,16361,13791,-999:REM total income 10200 DATA 2,35,0,7950,7409,7775,7713,6465,6475,8994,9165,5874,3671,9096,9626,-999:REM tithe 10300 DATA 3,35,0,8532,8195,8414,8566,7293,7045,9831,9954,6465,4197,9746,12207,-999:REM conference 10400 DATA 4,35,0,3104,2503,2639,2747,2918,3713,2941,2841,2552,1785,4027,3123,-999:REM local fundsin 10500 DATA 5,35,0,3044,3723,2996,3331,3915,2259,3492,2924,4313,3752,2628,3042,-999:REM local expenses 15000 NUM=1:GOSUB 900:LPRINT "470 400 moveto 530 400 lineto stroke 540 400 moveto (total income) show" 15010 NUM=2:GOSUB 900:LPRINT "470 390 moveto 530 390 lineto stroke 540 390 moveto (tithe) show" 15020 NUM=3:GOSUB 900:LPRINT "470 380 moveto 530 380 lineto stroke 540 380 moveto (confrence remittance) show" 15030 NUM=4:GOSUB 900:LPRINT "470 370 moveto 530 370 lineto stroke 540 370 moveto (LOCAL FUNDS IN) show" 15040 NUM=5:GOSUB 900:LPRINT "470 360 moveto 530 360 lineto stroke 540 360 moveto (LOCAL EXPENSES) show" 15050 NUM=1:GOSUB 900:LPRINT "176 371 moveto 225 371 lineto stroke ":LPRINT" 230 371 moveto (TAPPED SAVINGS 4000.00) show" 15999 RETURN Cheers Woody