Anonymous user
File extension is in extensions list: Difference between revisions
File extension is in extensions list (view source)
Revision as of 20:50, 11 August 2014
, 9 years ago→{{header|REXX}}: added REXX code to handle a path in the filename, also to handle a filename with multiple periods at the tail end.
m (→{{header|REXX}}: added a programming note.) |
(→{{header|REXX}}: added REXX code to handle a path in the filename, also to handle a filename with multiple periods at the tail end.) |
||
Line 35:
=={{header|REXX}}==
Programming note: extra code was added to display some error/warning messages, and also to handle the case of the filename having a ''path''.
<lang rexx>/*REXX program displays if a filename has a known extension (per a list)*/
extentions='.bat .cmd .com .
parse arg fn /*get the filename from the C.L. */
fn=strip(fn) /*remove any superfluous blanks. */
if fn=='' then exit /*No fn specified? Then exit.*/
afn=translate(fn,'/',"\") /*handle both versions of pathSep*/
afn=substr(fn,lastpos('/',afn)+1) /*pick off the filename from path*/
▲ say 'Filename ' fn " has no extension."
p=lastpos('.',afn) /*find the last position of a
if p==0 | p==length(afn) then do /*no dot or dot is at end of
exit
end
ft=substr(afn,p) /*pickoff the fileType (fileExt).*/
upper ft extentions /*uppercase a couple of REXX vars*/
if wordpos(ft,extentions)==0 then _='an unknown'
|