Line Filters in Scilab
Our line filter program reads input from stdin, processes it, and then prints a derived result to stdout. This example writes a capitalized version of all input text. You can use this pattern to write your own Scilab line filters.
In Scilab, we use the mgetl()
function to read all lines from standard input. We then process each line using a for loop, converting it to uppercase with the convstr()
function. The mprintf()
function is used to write the uppercased line to stdout.
To try out our line filter, first make a file with a few lowercase lines:
Then use the line filter to get uppercase lines:
Note that in Scilab, we run scripts using the scilab
command with the -nwni
option (No Window, No Interactive mode) and the -f
option to specify the script file.
This Scilab version provides similar functionality to the original Go program, reading input lines, converting them to uppercase, and printing the result. The error handling is simplified, as Scilab’s mgetl()
function doesn’t provide the same level of granular error reporting as Go’s bufio.Scanner
.