home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The World of Computer Software
/
World_Of_Computer_Software-02-386-Vol-2of3.iso
/
c
/
carsconv.zip
/
CARSCONV.BAS
next >
Wrap
BASIC Source File
|
1992-05-07
|
2KB
|
81 lines
CONST FILENOTFOUND = 53
ON ERROR GOTO ErrorHandler
file$ = "DIR" 'first 3 letters of file name
CI$ = "1" 'first file number as a string
REM CI$ = COMMAND$
CI = VAL(CI$) 'make CI the value of CI$
dir$ = "DIR"
FOR I = 1 TO 80 'Loop throug all Descrip. Files
Number$ = MID$(STR$(I), 2) 'let Number$ = loop number
StartFile$ = "DIR" + Number$ + "." 'assign file to read from
EndFile$ = StartFile$ + "TXT" 'assign file to write to
CLS 'clear screen
PRINT "Processing: "; StartFile$ 'print to screen old text file
PRINT "Into NewFile: "; EndFile$ 'print to screen new text file
GOSUB GetFileInfo 'goto file reading subroutine
NEXT I
END
GetFileInfo: 'SUBROUTINE GETFILEINFO
'
'OPEN StartFile$ FOR INPUT AS #1 'Open origin file as file #1
'TotalRecNum = 0
'DO UNTIL EOF(1) 'Do Loop for getting # of Records
' LINE INPUT #1, temp$ 'Read File into Temp$
'REM PRINT Temp$
' TotalRecNum = TotalRecNum + 1 'Increase # Records by 1
'LOOP
'CLOSE #1 'close origin file
OPEN StartFile$ FOR INPUT AS #1 'open origin file as file #1
OPEN EndFile$ FOR OUTPUT AS #2 'open destination file as file #2
Recnum = 1
COUNTER = 1
LINE INPUT #1, HEADER1$
LINE INPUT #1, HEADER2$
LINE INPUT #1, HEADER3$
LINE INPUT #1, Entry$
PRINT #2, HEADER1$
PRINT #2, HEADER2$
PRINT #2, HEADER3$
DO UNTIL EOF(1)
LOCATE 4, 1
PRINT "Processing Record Number ", COUNTER
GOSUB TextLine
COUNTER = COUNTER + 1
LOOP
CLOSE #1
CLOSE #2
RETURN
TextLine:
FOR J = 1 TO 9
IF EOF(1) THEN RETURN
LINE INPUT #1, AddLine$
IF MID$(AddLine$, 1, 1) = " " THEN
Entry$ = Entry$ + MID$(AddLine$, 33)
ELSE
PRINT #2, Entry$
LOCATE 6, 1
' PRINT Entry$
' LOCATE 15, 1
' INPUT a$
Entry$ = AddLine$
EXIT FOR
END IF
NEXT J
RETURN
ErrorHandler:
IF ERR = FINENOTFOUND THEN
END
ELSE
LOCATE 10
PRINT
END
END IF
RESUME