File extension is in extensions list: Difference between revisions
Content added Content deleted
Alextretyak (talk | contribs) (Added 11l) |
m (→{{header|REXX}}: changed some variable names and comments.) |
||
Line 1,517: | Line 1,517: | ||
=={{header|REXX}}== |
=={{header|REXX}}== |
||
This REXX version handles the extra credit requirement. |
This REXX version handles the extra credit requirement. |
||
<lang rexx>/*REXX |
<lang rexx>/*REXX pgm displays if a filename has a known extension (as per a list of extensions). */ |
||
$= 'zip rar 7z gz archive A## tar.bz2'; upper $ /*a list of "allowable" file extensions*/ |
$= 'zip rar 7z gz archive A## tar.bz2'; upper $ /*a list of "allowable" file extensions*/ |
||
parse arg fn /*obtain optional argument from the CL.*/ |
parse arg fn /*obtain optional argument from the CL.*/ |
||
@.= /*define the default for the @. array.*/ |
@.= /*define the default for the @. array.*/ |
||
if fn\='' then @.1 = strip(fn) |
if fn\='' then @.1 = strip(fn) /*A filename specified? Then use it. */ |
||
else do; @.1 = "MyData.a##" /* |
else do; @.1 = "MyData.a##" /*No " " Else use list*/ |
||
@.2 = "MyData.tar.Gz" |
@.2 = "MyData.tar.Gz" |
||
@.3 = "MyData.gzip" |
@.3 = "MyData.gzip" |
||
Line 1,531: | Line 1,531: | ||
@.8 = "MyData_v1.0.bz2" |
@.8 = "MyData_v1.0.bz2" |
||
end |
end |
||
#=words($) |
#= words($) |
||
do j=1 while @.j\=='' |
do j=1 while @.j\==''; @@= @.j; upper @@ /*traipse through @ file extension list*/ |
||
do k=1 for # until right(@@, L)==x /*Search $ list, is extension in list? */ |
|||
⚫ | |||
do k=1 for # until right(file, length(x) )==x /*Search $ list, is ext in list?*/ |
|||
⚫ | |||
end /*k*/ /* [↓] display file, and a nay or yea.*/ |
end /*k*/ /* [↓] display file, and a nay or yea.*/ |
||
⚫ | |||
⚫ | |||
end /*j*/ /*stick a fork in it, we're all done. */</lang> |
end /*j*/ /*stick a fork in it, we're all done. */</lang> |
||
{{out|output|text= when using the default input:}} |
{{out|output|text= when using the default input:}} |