The [file_stdin]
method takes no parameters and returns a [file]
object that can interact with standard in I/O stream.
var(stdin) = file_stdin
The example below is taken from the lasso9 binary that allows you to interactively run lasso commands. The code displays a prompt to standard out and waits for input. It reads the input from standard in and tries to process it as Lasso code.
Code
while(true) => {
stdout('>: ')
local(r = file_stdin->readSomeBytes(1024, 1000))
while(not #r or #r->size == 0) => {
#r = file_stdin->readSomeBytes(1024, 1000)
}
protect => {
handle_failure => {
stdoutnl(''+error_code+' '+error_msg)
}
local(cb = sourcefile(string(#r), 'interactive', true, false))
stdoutnl(#cb())
}
}
Please note that periodically LassoSoft will go through the notes and may incorporate information from them into the documentation. Any submission here gives LassoSoft a non-exclusive license and will be made available in various formats to the Lasso community.
©LassoSoft Inc 2015 | Web Development by Treefrog Inc | Privacy | Legal terms and Shipping | Contact LassoSoft
Recent Comments