RosettaCodeData/Task/Multiple-distinct-objects/Seed7/multiple-distinct-objects.s...

21 lines
628 B
Plaintext

$ include "seed7_05.s7i";
const func array file: openFiles (in array string: fileNames) is func
result
var array file: fileArray is 0 times STD_NULL; # Define array variable
local
var integer: i is 0;
begin
fileArray := length(fileNames) times STD_NULL; # Array size computed at run-time
for key i range fileArray do
fileArray[i] := open(fileNames[i], "r"); # Assign multiple distinct objects
end for;
end func;
const proc: main is func
local
var array file: files is 0 times STD_NULL;
begin
files := openFiles([] ("abc.txt", "def.txt", "ghi.txt", "jkl.txt"));
end func;