TIP: Click on subject to list as thread! ANSI
echo: power_bas
to: ALL
from: DAVE NAVARRO
date: 1995-06-05 15:34:00
subject: Reading From Stdin

'Read input from STDIN for PowerBASIC 3.1
'by Dave Navarro, Jr.
$LIB IPRINT ON
DEFINT A-Z
'This example will will display a text file which is redirected to it.
'
'Example:  STDIN < c:\autoexec.bat
Ch = StdIn
WHILE Ch > 0
  IF Ch  10 THEN   'ignore line-feeds
    PRINT CHR$(Ch);
  END IF
  Ch = StdIn
WEND
'===========================================================================
' StdIn - Read a char from STDIN and return its ASCII value.  If it's an
'         extended keycode, it's returned as a negative value.
'
' Note:  Great for reading information which is redirected from a file.
'
FUNCTION StdIn PUBLIC
  ! push    DS                      ;
  ! mov     AH, &H0B                ; DOS function 0Bh, check STDIN
  ! int     &H21                    ; call DOS
  ! cmp     AL, &HFF                ; FFh if char is available
  ! je      ReadChar                ; yes, get it
  ! xor     AX, AX                  ; clear AX
  ! jmp     Done                    ; yes, no character ready so exit
ReadChar:
  ! mov     AH, &H07                ; DOS function 07h, get char from STDIN
  ! int     &H21                    ; call DOS
  ! xor     AH, AH                  ; clear AH
  ! or      AL, AL                  ; was char a zero?  (extended key)
  ! jnz     Done                    ; no, exit
  ! mov     AH, &H07                ; DOS function 07h, get char from STDIN
  ! int     &H21                    ; call DOS
  ! xor     AH, AH                  ; clear AH
  ! neg     AX                      ; make it negative
Done:
  ! pop     DS
  ! mov     FUNCTION, AX
END FUNCTION
---
 þ QMPro 1.53 þ Pi aren't square! Cornbread are square!
          
--- QScan v1.065b
---------------
* Origin: Nitelog BBS Monterey CA (408) 655-1096 (1:216/303) (1:216/303)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.