• Welcome to OS2World OLD-STATIC-BACKUP Forum.
 

News:

This is an old OS2World backup forum for reference only. IT IS READ ONLY!!!

If you need help with OS/2 - eComStation visit http://www.os2world.com/forum

Main Menu

Use Filespec to extract path info. from URLs

Started by jep, 2008.04.10, 10:14:54

Previous topic - Next topic

jep

Marked as: Easy
Hello,
Did you know that you can use the built in function FILESPEC to to extract drive, path and filename from not only local paths but also network paths (UNC-path) and URLs?

Note that the last example "file:///c:/.." contain 2 "drives", so you may need to create additional code for that scenario.

/* Filespec to extract drive, path and filename from URL */

url.1 = 'C:\os2\cmd.exe'
url.2 = '\\network_server\path\filename.txt'
url.3 = 'http://www.os2world.com/index.html'
url.4 = 'ftp://xwp.netlabs.org/readme.txt'
url.5 = 'file:///c:/temp/doc/faq.txt'
url.0 = 5

do i = 1 to url.0
   say 'Drive: 'filespec( 'D', url.i )
   say 'Path: 'filespec( 'P', url.i )
   say 'Name: 'filespec( 'N', url.i )
end