Walk a directory/Non-recursively: Difference between revisions
Walk a directory/Non-recursively (view source)
Revision as of 11:31, 16 February 2024
, 3 months ago→{{header|Wren}}: Minor tidy
No edit summary |
m (→{{header|Wren}}: Minor tidy) |
||
(2 intermediate revisions by 2 users not shown) | |||
Line 750:
=={{header|Elena}}==
ELENA
<syntaxhighlight lang="elena">import system'io;
import system'routines;
Line 759:
var dir := Directory.assign("c:\MyDir");
dir.getFiles("a.*").forEach
}</syntaxhighlight>
Line 1,814:
Finished
</pre>
=={{header|RPL}}==
{{works with|Halcyon Calc|4.2.7}}
The very first instruction of this program <code>VARS</code> returns the list of all current files and subdirectories. The rest of the code retains the names that comply with the pattern given in input, and which are not directories. To do so, the program attempts to recall the contents of each object on the stack through <code>RCL</code>: if an error occurs, the object is then a directory and shall not be processed further.
≪ VARS → filter list
≪ { } 1 list SIZE '''FOR''' j
list j GET
'''IFERR''' DUP RCL '''THEN''' DROP2
'''ELSE'''
DROP →STR 2 OVER SIZE 1 - SUB
'''IF''' DUP filter POS '''THEN''' + ELSE DROP '''END'''
'''END'''
'''NEXT'''
≫ ≫
'WKDIR' STO
"T" WKDIR
{{out}}
<pre>
1: { "T" "TESTPGM" "FACTN" }
</pre>
Line 2,086 ⟶ 2,107:
=={{header|Wren}}==
{{libheader|Wren-pattern}}
<syntaxhighlight lang="
import "./pattern" for Pattern
var walk = Fn.new { |dir, pattern|
|