File: stdStreams.fal

package info (click to toggle)
falconpl 0.9.6.9-git20120606-2
  • links: PTS, VCS
  • area: main
  • in suites: wheezy
  • size: 46,176 kB
  • sloc: cpp: 181,389; ansic: 109,025; yacc: 2,310; xml: 1,218; sh: 403; objc: 245; makefile: 82; sql: 20
file content (44 lines) | stat: -rw-r--r-- 907 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/*
   Falcon Samples.

   Standard I/O streams test.

	This just checks for standard VM streams to work correctly
	by reversing the input stream to the output stream (line
   by line) and then writing the number of parsed line to
	the standard error.
*/

> '
   Test for ''standard input stream''
   Enter some text line; it will be printed in reverse order to
   confirm it has been read.

   After entering some line, close the stream with CTRL+D on UNIX
   and CTRL+Z (then enter) on MS-Windows. The count of read lines
   will be printed.'

sInput = stdIn()
sOutput = stdOut()
sError = stdErr()

count = 0
line = ""

while not sInput.eof()

	if sInput.readLine( line, 512 ) == 0: continue

   if line.len() == 1
      sOutput.write( line )
   else
      sOutput.write( line[-1:0] )
   end
   sOutput.write( "\n" )
	count++
end

sError.write( @"\nParsed $count lines\n\n" )

/* End of stdStreams.fal */