Program to Add a Segment Miles Column to a Cue Sheet

REM fIle = ADDSEG.BAS REM This BASIC Program reads an MS-DOS ASCII file and creates a REM new one with a segment 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. COLOR 10 DEFINT I-K OPTION BASE 1 1 PRINT "This program creates a Segment Miles Col. from a Cue Sheet" PRINT " with a Total Miles Column only." PRINT PRINT "The BASIC Program ADDTOT.BAS will return a Total Miles" PRINT "Column from an input file with a Segment Miles Column." PRINT PRINT " The name of the input file is a Key-in." PRINT " A Key-in will also select the name of the resulting out-" PRINT "put file. It must be checked before erasing the input file." 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 "Turns run from Cols 13-19, so center on col 16." 2 PRINT "Descriptions start in Col 21." PRINT FILES PRINT "Key in the filespec that needs a Segment Miles Column. " INPUT " ", SRCENAME$ OPEN SRCENAME$ FOR INPUT AS #1 PRINT PRINT "Key in the name of the resulting output file. " INPUT " ", RIDENAME$ OPEN "O", #2, RIDENAME$ PRINT LK=0 ' Initialize input file line counter 10 IF EOF(1) GOTO 40 LINE INPUT #1, TEXTNAME$ LK=LK + 1 IF TEXTNAME$>< ".." THEN GOTO 20 TD$=TEXTNAME$ LINE INPUT #1, TEXTNAME$ RULER$ = TEXTNAME$ OD$=CHR$(13) PRINT #2, TD$ + OD$ + RULER$ GOTO 10 REM BEGIN MATH TO CREATE SEGMENT MILES VALUE 20 A2$=MID$(TEXTNAME$,4,1) IF A2$<>"." THEN PRINT TEXTNAME$: PRINT #2,TEXTNAME$:GOTO 10 HUNDREDS=VAL(MID$(TEXTNAME$,1,1)) TENS=VAL(MID$(TEXTNAME$,2,1)) UNITS=VAL(MID$(TEXTNAME$,3,1)) TENTHS=VAL(MID$(TEXTNAME$,5,1)) NOWTOT=100*HUNDREDS + 10*TENS + UNITS + TENTHS/10 IF NOWTOT=0 THEN SEGCOL=0:LASTOT=0:GOTO 30 SEGCOL = NOWTOT - LASTOT LASTOT = NOWTOT REM NUMBERS FOR MILEAGE RECALCULATED. REM Verify Action area & 1st col. of Descr. area are CAPITALIZED. 30 FOR KAP =12 TO 21 ZA$=MID$(TEXTNAME$,KAP,1) KZA=ASC(ZA$) IF (KZA>96) AND (KZA<123) THEN KZA=KZA-32 MID$(TEXTNAME$,KAP,1)=CHR$(KZA) NEXT KAP REM Capital letters added REM Print reworked line NEWRIGHTEND$=MID$(TEXTNAME$,12) FMT$="##.#" PRINT LEFT$(TEXTNAME$,7); PRINT USING FMT$;SEGCOL; PRINT NEWRIGHTEND$ PRINT #2, LEFT$(TEXTNAME$,7); PRINT #2, USING FMT$; SEGCOL; PRINT #2, NEWRIGHTEND$ GOTO 10 40 PRINT PRINT "A cue sheet with a segment mileage column has been generated." PRINT "The source filespec was "; SRCENAME$ PRINT "The output filespec was "; RIDENAME$ CLOSE SYSTEM END


Return to previously viewed page
Go to Program Explanation Page
Go to Home Page