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 >
BASIC Source File  |  1992-05-07  |  2KB  |  81 lines

  1. CONST FILENOTFOUND = 53
  2. ON ERROR GOTO ErrorHandler
  3. file$ = "DIR"                         'first 3 letters of file name
  4. CI$ = "1"                             'first file number as a string
  5. REM CI$ = COMMAND$                      
  6. CI = VAL(CI$)                         'make  CI the value of CI$
  7. dir$ = "DIR"
  8.                                             
  9. FOR I = 1 TO 80                              'Loop throug all Descrip. Files
  10.         Number$ = MID$(STR$(I), 2)           'let Number$ = loop number
  11.         StartFile$ = "DIR" + Number$ + "."   'assign file to read from
  12.         EndFile$ = StartFile$ + "TXT"        'assign file to write to
  13.         CLS                                  'clear screen
  14.         PRINT "Processing: "; StartFile$       'print to screen old text file
  15.         PRINT "Into NewFile: "; EndFile$       'print to  screen new text file
  16.         GOSUB GetFileInfo                    'goto file reading subroutine
  17.         
  18.  
  19. NEXT I
  20.  
  21. END
  22. GetFileInfo:                                'SUBROUTINE GETFILEINFO
  23. '
  24. 'OPEN StartFile$ FOR INPUT AS #1             'Open origin file as file #1
  25. 'TotalRecNum = 0
  26. 'DO UNTIL EOF(1)                             'Do Loop for getting # of Records
  27. '        LINE INPUT #1, temp$                'Read File into Temp$
  28. 'REM     PRINT Temp$
  29. '        TotalRecNum = TotalRecNum + 1       'Increase # Records by 1
  30. 'LOOP
  31. 'CLOSE #1                                    'close origin file
  32. OPEN StartFile$ FOR INPUT AS #1             'open origin file as file #1
  33. OPEN EndFile$ FOR OUTPUT AS #2              'open destination file as file #2
  34. Recnum = 1
  35. COUNTER = 1
  36. LINE INPUT #1, HEADER1$
  37. LINE INPUT #1, HEADER2$
  38. LINE INPUT #1, HEADER3$
  39. LINE INPUT #1, Entry$
  40. PRINT #2, HEADER1$
  41. PRINT #2, HEADER2$
  42. PRINT #2, HEADER3$
  43. DO UNTIL EOF(1)
  44.         LOCATE 4, 1
  45.         PRINT "Processing Record Number  ", COUNTER
  46.         GOSUB TextLine
  47.         COUNTER = COUNTER + 1
  48. LOOP
  49. CLOSE #1
  50. CLOSE #2
  51. RETURN
  52.  
  53. TextLine:
  54. FOR J = 1 TO 9
  55.    IF EOF(1) THEN RETURN
  56.    LINE INPUT #1, AddLine$
  57.    IF MID$(AddLine$, 1, 1) = " " THEN
  58.        Entry$ = Entry$ + MID$(AddLine$, 33)
  59.    ELSE
  60.        PRINT #2, Entry$
  61.        LOCATE 6, 1
  62. '       PRINT Entry$
  63. '       LOCATE 15, 1
  64. '       INPUT a$
  65.        Entry$ = AddLine$
  66.        EXIT FOR
  67.    END IF
  68. NEXT J
  69. RETURN
  70.  
  71. ErrorHandler:
  72.    IF ERR = FINENOTFOUND THEN
  73.       END
  74.     ELSE
  75.       LOCATE 10
  76.       PRINT
  77.       END
  78.     END IF
  79. RESUME
  80.  
  81.