[fpc-pascal]opening files from a text list
    Laurent Cocea 
    cocea at canada.com
       
    Sat Nov 29 15:12:42 CET 2003
    
    
  
Or you could wrap it around a Perl script. Perl is particularly good at
parsing text and generating arrays from strings and vice-versa. And then
you can call your Pascal-generated code from within the script using the
array elements as arguments, liek this:
#!/usr/bin/perl -w
my @arguments;
my $arg;
open INF "<your_file.txt";
while (<INF>) {
  chomp; # delete EOLN char
  @arguments = split(/ /, $_); # generate arguments array from string
}
close INF;
foreach $arg @args {
  if ( $arg =~ m/[a-z][0-9]\_/i ) { # validate param string
    system("your_pascal-generated_binary_here $arg");
  } else {
    print "Skipped invalid argument $arg.\n";
  }
}
and then your Pascal code would use ParamStr() to read "command line"
arguments, that is, the file name(s).
    
    
More information about the fpc-pascal
mailing list