Introduction


W
hen downloading text files from the internet these files often have the wrong line breaks because the line breaks are of the type of the server's operation system. While Unix systems use a single "Line Feed" to mark the end of a line DOS and Windows systems use a "Carriage Return" followed by a "Line Feed".

T
his program will convert line breaks from Unix format (LF) to DOS format (CR/LF). It also shows how to handle command line arguments and how to convert short file names to long file names.
Unix to DOS


T
his program expects a file name as command line argument. If this file name is missing then it prompts the user to specify a file. When using Drag&Drop (drawing a file on this program's icon) Windows will pass the dropped file's name in short file format. When writing back the file it would turn to the short file name. So the file name argument has to be converted to long file name format first.

'Author     : Daniel, Master Sourcerer at Kitana's Cas...
'Last change: January 30, 2004
'Email      : sourcerer@kitana.org


'Replaces Unix lines breaks (LF) with DOS line breaks ...

#DIM ALL



'Main program
FUNCTION PBMAIN&
  LOCAL F$,P$
  LOCAL A$,I&,J&,N&

  'read file name
  F$=TRIM$(COMMAND$)
  IF F$=""THEN  'no file name specified so prompt user
    LINE INPUT"File to convert: ",F$
    F$=TRIM$(F$)
    IF F$=""THEN EXIT FUNCTION
  END IF

  'check if file exists and get its long file name
  I&=INSTR(-1,F$,"\")
  P$=LEFT$(F$,I&)
  F$=DIR$(F$)  'DIR$ converts short file names to long...
  IF F$=""THEN
    PRINT"File not found"
Arena Play Ground Throne Room Theatre Hall Library Back Print Next page Last page