FixScript

Forum: General Discussion: FixScript IO


Direct console input
2023/01/11 13:44
First, thank you for your work.

Is there any functionality/example to handle direct console input, without using a GUI, such as a getline()? Or typed inputs like get_int(), get_float() or get_string()?

jezek2
2023/01/11 14:14
You can use a ProcessStream wrapped in BufferedStream which provides ability to read lines. It is reading the raw bytes so you may have problems with encodings (if it's in UTF-8 you can use the built-in string_from_utf8 function).

Documentation:
https://www.fixscript.org/docs/io/process_stream.html
https://www.fixscript.org/docs/io/buffered_stream.html

Here is an example:

use "classes";

import "io/stream";
import "io/process";

function main()
{
var stream = BufferedStream::create(ProcessStream::get());
var line = {""};
while (stream.read_line(line) != null) {
log("line='"+line+"'");
}
log("end");
}

Reply

Name:
Content:
Confirmation code:
 
  (type the letters shown in the picture)