[fpc-pascal] EOF on stdin

Mark Morgan Lloyd markMLl.fpc-pascal at telemetry.co.uk
Sat Dec 8 13:27:05 CET 2007

I'm trying to distinguish between a case where there is no parameter on the 
command line and where there is piped input. The code below works under Win-32 
but under Linux Eof() waits for input:

   IF ParamCount = 0 THEN BEGIN		(* Case (1) or (2) *)
     debug('No parameters (case 1 or 2)');
       AssignFile(input, '');		(* Standard input		*)
       Reset(input);	// Returns zero
	IF Eof(input) THEN BEGIN	(* Case (1)	*)
           debug('At EOF (case 1)');

// Nothing on command line.

	END ELSE BEGIN			(* Case (2)	*)
           debug('Not at EOF (case 2)');

// Got piped input.

If I start it under linux by piping an eof (i.e. echo -n |) it works.

I'm sure this is something that's been looked at before- how do I get it to work?

Mark Morgan Lloyd
markMLl .AT. telemetry.co .DOT. uk

[Opinions above are the author's, not those of his employers or colleagues]

More information about the fpc-pascal mailing list