home *** CD-ROM | disk | FTP | other *** search
/ Crawly Crypt Collection 1 / crawlyvol1.bin / bbs / addcrlf / addcrlf.lst next >
File List  |  1990-01-12  |  3KB  |  76 lines

  1. '
  2. ' ADDCRLF v1.0 - J. Webb, DeltaVision Systems. No CopyRight, but please don't
  3. '                distribute modified versions.
  4. '
  5. $B+,U-,I-,E#,P<                                              ! Compiler switches
  6. '
  7. PRINT "ADDCRLF v1.0 - J. Webb, DeltaVision Systems. No CopyRight."
  8. PRINT
  9. '
  10. ON ERROR GOSUB trap                                            ! Trap any errors
  11. '
  12. IF BYTE{BASEPAGE+128}=0                               ! No command line present?
  13.   '
  14.   help                                                        ! Show help & exit
  15.   '
  16. ELSE                                                     ! Command line present!
  17.   '
  18.   f$=SPACE$(BYTE{BASEPAGE+128})                                ! Make some space
  19.   BMOVE BASEPAGE+129,V:f$,LEN(f$)                ! Move command line into string
  20.   '
  21.   IF NOT EXIST(f$)                                    ! Does file doesn't exist?
  22.     PRINT "File Not Found!"                                       ! Show message
  23.     PRINT
  24.     help                                                      ! Show help & exit
  25.   ELSE                                                         ! File does exist
  26.     '
  27.     PRINT "Processing file "+UPPER$(f$)                  ! Show what we're doing
  28.     OPEN "I",#1,f$                                         ! Open file for input
  29.     IF LOF(#1)<2                                         ! Smaller than 2 bytes?
  30.       CLOSE #1                                                     ! Close input
  31.       OPEN "A",#1,f$                                   ! Open file for appending
  32.       PRINT #1                                                     ! Append CRLF
  33.     ELSE                                              ! Same/Longer than 2 bytes
  34.       SEEK #1,LOF(#1)-2                                   ! Go to end of file -2
  35.       IF INP(#1)=13 AND INP(#1)=10                      ! If last bytes are CRLF
  36.         PRINT "File ends in CRLF"                                ! Nothing to do
  37.       ELSE                                              ! Last bytes aren't CRLF
  38.         CLOSE #1                                                   ! Close input
  39.         PRINT "Adding CRLF"                                   ! Have to add CRLF
  40.         OPEN "A",#1,f$                                 ! Open file for appending
  41.         PRINT #1                                                   ! Append CRLF
  42.       ENDIF
  43.     ENDIF
  44.     CLOSE                                                       ! Close any file
  45.     '
  46.   ENDIF
  47. ENDIF
  48. END
  49. '
  50. > PROCEDURE help                                        ! Show help, wait & exit
  51.   '
  52.   PRINT " Makes sure a text file ends with CRLF.";
  53.   PRINT " Supply the path+name+extension of the"
  54.   PRINT " file to check on the command line."
  55.   PRINT
  56.   PRINT "Any Key or wait 10 seconds..."
  57.   '
  58.   t%=TIMER
  59.   REPEAT
  60.   UNTIL TIMER-t%>2000 OR INP?(2)
  61.   '
  62.   IF INP?(2)
  63.     ~INP(2)
  64.   ENDIF
  65.   '
  66.   END
  67.   '
  68. RETURN
  69. > PROCEDURE trap                                  ! Jump here if an error occurs
  70.   '
  71.   PRINT CHR$(7);"ERROR ";ERR                                 ! Show error number
  72.   PAUSE 50                                                     ! Wait one second
  73.   END                                                                     ! Exit
  74.   '
  75. RETURN
  76.