Jump to content

File extension is in extensions list: Difference between revisions

m
→‎{{header|REXX}}: changed some variable names and comments.
(Added 11l)
m (→‎{{header|REXX}}: changed some variable names and comments.)
Line 1,517:
=={{header|REXX}}==
This REXX version handles the extra credit requirement.
<lang rexx>/*REXX programpgm displays if a filename has a known extension (as per a list of EXTsextensions). */
$= 'zip rar 7z gz archive A## tar.bz2'; upper $ /*a list of "allowable" file extensions*/
parse arg fn /*obtain optional argument from the CL.*/
@.= /*define the default for the @. array.*/
if fn\='' then @.1 = strip(fn) /*A filename specified? Then use it. */
else do; @.1 = "MyData.a##" /*No " " elseElse use list*/
@.2 = "MyData.tar.Gz"
@.3 = "MyData.gzip"
Line 1,531:
@.8 = "MyData_v1.0.bz2"
end
#= words($)
 
do j=1 while @.j\==''; @@= @.j; upper @@ /*traipse through @ listfile ofextension file exts.list*/
file=@.j; upper file do k=1 for # until right(@@, L)==x /*getSearch $ alist, filename;is andextension thenin uppercaselist? it*/
x= . || word($, k); L=length(x) /*construct the extension of the file. */
 
do k=1 for # until right(file, length(x) )==x /*Search $ list, is ext in list?*/
x=. || word($, k) /*construct the extension of the file. */
end /*k*/ /* [↓] display file, and a nay or yea.*/
say right(@.j, 40) ' ' right( word( "false true", 1 + (k<=#) ), 5)
 
say right(@.j, 40) ' ' right( word( "false true", 1 + (k<=#) ), 5)
end /*j*/ /*stick a fork in it, we're all done. */</lang>
{{out|output|text=&nbsp; when using the default input:}}
Cookies help us deliver our services. By using our services, you agree to our use of cookies.