I have this problem in pascal:
I want to include a variable in file name while assigning a text file to variable of textfile.
I have a text file called 'numoffiles.txt' with one integer number in it
I read it and set variable a to that number in file (-read(f,a)--)
Then I close 'numoffiles.txt'
I have a files file_1, file_2, file_3 and so on in same folder
I want to open in pascal the number of files defined by number in file 'numoffiles.txt', which is now the value of variable a
So when I type in 'numoffiles.txt' '2', I want to open in pascal just file_1 and file_2
I was thinking about something like this:
for i:= 1 to a do begin assign ([B]f,'file_',i,'.txt'[/B]); ([U]include variable into file name[/U]) reset (f); read (something unimportant here); close (f); end;
But it doesnt work
So just want to know if there is a way how to define the number of files that are going to be read
I dont want to read every file separately (but of course - if its only way i'll have to)
Hope you at least understand definition of my problem
Thanks for answers