File extension is in extensions list: Difference between revisions
Content added Content deleted
m (→{{header|ruby}}: Ruby with a capital R) |
(→{{header|REXX}}: added the REXX language. -- ~~~~) |
||
Line 34: | Line 34: | ||
</lang> |
</lang> |
||
=={{header|REXX}}== |
|||
<lang rexx>/*REXX program displays if a filename has a known extension (per a list)*/ |
|||
extentions='.bat .cmd .com .ini .txt' /*this would be the complete list*/ |
|||
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.*/ |
|||
p=lastpos('.',fn); if p==0 then do |
|||
say 'Filename ' fn " has no extension." |
|||
exit |
|||
end |
|||
ft=substr(fn,p) /*pickoff the fileType (fileExt).*/ |
|||
upper ft extentions /*uppercase a couple of REXX vars*/ |
|||
if wordpos(ft,extentions)==0 then _='an unknown' |
|||
else _= 'a known' |
|||
say 'Filename ' fn "has" _ 'extension.'</lang> |
|||
=={{header|Scala}}== |
=={{header|Scala}}== |