REM     Prog to sum the tonnages of each commodity by tract
REM     makes a large matrix of tract by commodity number

        INPUT "enter input filename"; f1$
        INPUT "enter output filename, no extension"; f2$

        INPUT "enter max number of tracts"; t
        INPUT "enter tract prefix ie. S,N"; PR$
        PR$ = LEFT$(PR$, 1)
        f3$ = f2$ + "X.txt"
        f2$ = f2$ + ".txt"

        DIM matrix(t, 41)
        DIM matrixx(t, 41)

        OPEN f1$ FOR INPUT AS #1
        OPEN f2$ FOR OUTPUT AS #2
        OPEN f3$ FOR OUTPUT AS #3

REM     read a line and populate the matrix

        FOR i = 1 TO 5000
        IF EOF(1) THEN 500
        INPUT #1, tr, model, comm, comx, com90, com50, com10, com5, com1
        value = (com90 * .9 + com50 * .5 + com10 * .1 + com5 * .05 + com1 * .01) / 1.56
        matrix(tr, comm) = matrix(tr, comm) + value
        matrixx(tr, comm) = matrixx(tr, comm) + comx
        NEXT i

500     FOR j = 1 TO t
        PRINT #2, PR$; j; ",";
        PRINT #3, PR$; j; ",";
        FOR k = 1 TO 40
        PRINT #2, matrix(j, k); ",";
        PRINT #3, matrixx(j, k); ",";
        NEXT k
        PRINT #2, matrix(j, 41)
        PRINT #3, matrixx(j, 41)
        NEXT j
        END


        

