Program to Add a Total Miles Column to a Cue Sheet
REM File = ADDTOT.BAS
REM This BASIC Program reads an MS-DOS ASCII file and creates a
REM new one with a total miles column. Select "Program Explanation
REM Page" at the bottom of this Page for details.
REM There is a brief description between statements #1 and #2 below.
REM BASIC is good for simple tasks being done by non s/w people.
REM The volunteers who make cue sheets needn't also be s/w wizards.
DEFINT I-N
COLOR 10
PRINT
OPTION BASE 1
1 PRINT " This program creates a file with a Total Miles Column "
PRINT "from a file with a Segment Miles Column only."
PRINT " The similar BASIC Program ADDSEG.BAS provides a Segment"
PRINT "Miles Column from an input file with a Total Miles Column."
PRINT
PRINT " The user supplies input & output file names."
PRINT
PRINT " The total miles format is XXX.X, and XX.X for segment."
PRINT "The decimal points are in cols 4 and 10, respectively."
PRINT "The Action Column is from cols 13-19."
2 PRINT "The Description Column starts in col 21."
PRINT
FILES
PRINT
PRINT "Enter the name of the existing file that needs a ";
PRINT "Total Miles Column. "
INPUT " ", SRCEFILE$
OPEN SRCEFILE$ FOR INPUT AS #1
PRINT
PRINT "Enter the name you want for the resulting output file. "
INPUT " ", OUTFILE$
OPEN "O", #2, OUTFILE$
PRINT
IF B$= "y" OR B$= "Y" THEN COLOR 3
TOTMLS=0
10 IF EOF(1) GOTO 50
LINE INPUT #1, INFILE$
IF INFILE$ >< ".." THEN GOTO 20
REM When the IF above is FALSE, the next few lines do the
REM WordStar Ruler line.
TD$=INFILE$
LINE INPUT #1, INFILE$
RULER$ = INFILE$
OD$=CHR$(13)
PRINT TD$
PRINT RULER$
PRINT #2, TD$ + OD$ + RULER$
GOTO 10
20 IF (LEN(INFILE$)<23) GOTO 30
REM The IF above senses short lines, speeding execution.
IF (ASC(MID$(INFILE$,12,1))=48) THEN MID$(INFILE$,12,1)=" "
REM The above IF removes the 2nd digit after the decimal point.
IF (ASC(MID$(INFILE$,10,1))=46) GOTO 40
REM The above IF senses a mileage line
30 PRINT INFILE$
PRINT #2, INFILE$
GOTO 10
REM Change Action area & 1st col. of Descr. area to CAPITAL LETTERS.
40 FOR KAP=13 TO 21
ZA$=MID$(INFILE$,KAP,1)
KZA=ASC(ZA$)
IF (KZA>96) AND (KZA<123) THEN KZA=KZA-32
MID$(INFILE$,KAP,1)=CHR$(KZA)
NEXT KAP
REM CAPITAL LETTERS added A/R
REM Begin math to create Total Miles Column
TENS=VAL(MID$(INFILE$,8,1))
UNITS=VAL(MID$(INFILE$,9,1))
TENTHS=VAL(MID$(INFILE$,11,1))
SEGAMT=10*TENS + UNITS + TENTHS/10
REM Hundreths aren't used anymore.
TOTMLS=TOTMLS + SEGAMT
REM Total miles value created
NEWRIGHTEND$=MID$(INFILE$,8)
FMT$ = "###.# "
PRINT USING FMT$;TOTMLS;
PRINT NEWRIGHTEND$
PRINT #2, USING FMT$;TOTMLS;
PRINT #2, NEWRIGHTEND$
GOTO 10
50 PRINT
PRINT "A CUE SHEET WITH A TOTAL MILES COLUMN HAS BEEN GENERATED."
PRINT "The source filespec was ";SRCEFILE$
PRINT "The output filespec was ";OUTFILE$
CLOSE
SYSTEM
END