Classic Computer Magazine Archive COMPUTE! ISSUE 48 / MAY 1984 / PAGE 159

PROGRAMMING THE TI

C. Regena

File Processing

Part 3

This month C. Regena concludes her three-part discussion on creating data files.

A Birthday List

Program 1 prints a birthday list of the students in a class. The same data file is used, and the information is arranged in order by birthdate. Line 180 is the OPEN statement for the printer (use your own printer configuration). Line 190 is the OPEN statement for the disk drive to read in information.

Line 210 reads in the date—again, in the same order that the items were saved. We will ignore some of the information, but all the items must be read in order. Line 250 combines several of the items into one variable T$. The birthday BD and T$ are actually arrays, so the items may be sorted. Lines 280–350 contain the sorting procedure to sort by birthday.

Line 360 and lines 510–560 print the header. Lines 370–480 print the information. Lines 380–400 print the month and day from the BD number that was saved. Line 410 prints a blank line between months. Lines 420–450 use POS and SEG$ to separate the T$ item back into its parts, then line 460 prints the information in columns using the IMAGE statement of line 200.

The Report Writer

Program 2 generates reports using the data saved in Program 1 of Part 2 (April 1984). Lines 160–200 present the option to print the report for one of the reading groups or for the whole class.

These reports will use a 132-column line, or compressed print (16.5 characters per inch). Line 210 OPENs device #1 for the printer. The previous reports used an 80-column line, which is the default value for most printers. VARIABLE 132 is used to designate a longer line before a carriage return. Line 230 sets my printer (TI 825, which is like the TI 840) to use compressed print. You will probably need a different command.

Some printers can use a certain CHR$ number. Other printers may require you to set certain hardware switches. I have used compressed print and the 132-column line so more can fit on the one line. The other two reports in this program may be printed with the regular printing.

Line 240 is the OPEN statement to read the data from the data file created by Program 1 (Part 2, April). Again, the variables are in the same order as they were saved. Line 280 checks for the end of the file. Lines 290–300 check to see if a particular group was chosen or if the whole class is to be printed. Lines 310–480 then print the first report. The student's R$ tally is separated using SEG$. Line 360 and line 410 are used to print information if only part of the ten weeks is used. If you have a different number of weeks in your report, you can change the 10 in lines 130, 410, 520, 560, 600, and 670, and the titles in lines 140 and 930–950.

Total Values

Variable names starting with T are total values. Lines 440–450 print total presentations divided by total possible weeks and the individual's percentage. Lines 500–630 print the totals for each week.

A bar graph report is printed in lines 640–700. Each asterisk represents a report, and the appropriate number of asterisks is printed for each week as a graph.

The final report in this program is to rank the students from high score to low score by percentage. Lines 720–780 contain the sort routine. The percentages were stored in the P array with the corresponding names in NN$. Lines 790–850 print the percents and names. Line 810 and the subroutine in lines 1000–1150 alphabetize the names of all students who have a zero score.

Console BASIC

You can, in fact, do file processing without Extended BASIC and all the peripherals. I used Extended BASIC mainly because of the ease in formatting the printing—lining up the columns. In regular console BASIC you can use subroutines to line up columns of numbers and the TAB function to start the columns right. See my January 1984 column in COMPUTE! for some suggestions on formatting and screen scrolling.

To use a printer you need the RS-232 interface plus the printer. A number of different name brands of printers can be used with the TI-99/4A. The printer manuals should tell you what features the printer has and how to control different features, such as the number of characters per inch and form feeds. Using the printer and RS-232 manuals, you can determine the appropriate printer configuration necessary for the OPEN state­ment. Without a printer, you can print on the screen—just keep within the 28 print columns and print a screen at a time or use a scrolling delay method so you can read the information as it is printed.

To use a disk drive you also need the disk controller or disk controller card for the Peripheral Expansion box. The disk controller or card comes with a command module and a manual that describes disk procedures. To use a cassette, simply change the "DSK1---" statements to "CS1" and change the VARIABLE to FIXED. The cassette system works fine—it just takes longer than the disk system.