[Pas2js] ExtractFileName function

warleyalex warleyalex at yahoo.com.br
Wed Jul 31 22:43:28 CEST 2019


var
  fullFileName : string;

begin
  // Set up a full file name with drive and path
  fullFileName := 'C:\Program Files\Borland\Delphi7\Projects\Unit1.dcu';

// Show the component parts of this full name
  console.log('Drive = '+ExtractFileDrive (fullFileName));
  console.log('Dir   = '+ExtractFileDir   (fullFileName));
  console.log('Path  = '+ExtractFilePath  (fullFileName));
  console.log('Name  = '+extractfilename  (fullFileName));
  console.log('Ext   = '+ExtractFileExt   (fullFileName));

  console.log(ExtractFileName_(fullFileName));
  console.log(ExtractFileNameWithoutExt_(fullFileName));


(* outputs this:

   Drive = C:    // ---> OK
   Dir   = C:      // ----> should  be C:\Program
Files\Borland\Delphi7\Projects
   Path  = C:     //----> should be C:\Program
Files\Borland\Delphi7\Projects\
   Name  = \Program Files\Borland\Delphi7\Projects\Unit1.dcu    // --->
should be Unit1.dcu
   Ext   = .dcu // ----> OK

   Unit1.dcu     // ---> OK
   Unit1           // ---> OK

 *)





--
Sent from: http://pas2js.38893.n8.nabble.com/


More information about the Pas2js mailing list