Difference between revisions of "Raw I/O"

From ScarletDME
Jump to navigation Jump to search
m (clarification of stdio usage)
 
(3 intermediate revisions by the same user not shown)
Line 1: Line 1:
==Raw terminal I/O in QM==
+
==Raw terminal I/O in ScarletDME==
  
If you want to read from input without any character translation, it's necessary to disable some of the helpful processing that QM does.  The input stream  
+
If you want to read from input without any character translation, it's necessary to disable some of the helpful processing that SD does.  By default the input stream  
 
is converted from lower case to upper case (and vice versa), and Ctrl-C is processed as a break character.  The output is formatted so as to require user to
 
is converted from lower case to upper case (and vice versa), and Ctrl-C is processed as a break character.  The output is formatted so as to require user to
press <return> after each screenful of characters.
+
press <return> after each screen full of characters.
  
 
The following bit of code completely disables ALL formatting:-
 
The following bit of code completely disables ALL formatting:-
Line 16: Line 16:
 
   term_settings<2> = 0              ;* Case inversion on?  (PTERM CASE mode)
 
   term_settings<2> = 0              ;* Case inversion on?  (PTERM CASE mode)
 
   ttyset term_settings              ;* set parameters
 
   ttyset term_settings              ;* set parameters
 +
 +
 +
Once you've done this, it is still necessary to take care getting piped standard input (stdio) into Scarlet.  Like this:-
 +
 +
      $include syscom err.h
 +
      count = 0
 +
      s = 1  ;* flag for more chars in stdin - we assume so at beginning
 +
      loop
 +
        count += 1
 +
        string=keyin()
 +
        if status() = er$eof then s = 0
 +
        query_string := string
 +
      while s
 +
      while count < 1000000  ;* upper size limit
 +
      repeat
  
  
 
Glen is working on a single statement that the compiler can interpret to do the case conversion disable.
 
Glen is working on a single statement that the compiler can interpret to do the case conversion disable.
  
Ashley Chapman 2009-04-05
+
Ashley Chapman 2009-09-23

Latest revision as of 07:28, 11 March 2010

Raw terminal I/O in ScarletDME

If you want to read from input without any character translation, it's necessary to disable some of the helpful processing that SD does. By default the input stream is converted from lower case to upper case (and vice versa), and Ctrl-C is processed as a break character. The output is formatted so as to require user to press <return> after each screen full of characters.

The following bit of code completely disables ALL formatting:-

  execute "TERM 32767,32767 NULL"
  echo off                          ;* Disables iput echoing
  prompt ""                         ;* Disables input prompt character
  junk=@(0, 0)                      ;* Disables output paging
  junk = junk                       ;* Supress compiler warning from above line
  term_settings = ttyget()          ;* get parameters
  term_settings<1> = 0              ;* Ctrl-C treated as the break key?  (PTERM BREAK mode)
  term_settings<2> = 0              ;* Case inversion on?  (PTERM CASE mode)
  ttyset term_settings              ;* set parameters


Once you've done this, it is still necessary to take care getting piped standard input (stdio) into Scarlet. Like this:-

     $include syscom err.h
     count = 0
     s = 1  ;* flag for more chars in stdin - we assume so at beginning
     loop
        count += 1
        string=keyin()
        if status() = er$eof then s = 0
        query_string := string
     while s
     while count < 1000000  ;* upper size limit 
     repeat


Glen is working on a single statement that the compiler can interpret to do the case conversion disable.

Ashley Chapman 2009-09-23