Redirection PB 3.2 
Author Message
 Redirection PB 3.2

Hi!,

Is there a way to determine whether output from a program is being
redirected to a file?

I make use out the STDOUT function supplied in the DOSUNIT.BAS file.

Tia

Tom



Sun, 20 Mar 2005 15:17:17 GMT  
 Redirection PB 3.2
Hi Tom,

In PB3.5, you can check out the CONSIN and CONSOUT functions in the
Reference Guide. These two functions can be used to determine the
redirection status of standard input and standard output respectively.

Unfortunately CONSIN and CONSOUT are not supported in PB/DOS 3.2, so I
suspect you'll have to dig into the DOS interrupt list... a search
over at www.ctyme.com might be useful in this regard.

BTW, you can upgrade from 3.2 to 3.5 for only $49+shipping these
days...

I hope this helps.  If you have any further questions, please do not
hesitate to ask!

Thanks!

Quote:

>Hi!,

>Is there a way to determine whether output from a program is being
>redirected to a file?

>I make use out the STDOUT function supplied in the DOSUNIT.BAS file.

>Tia

>Tom

Lance
powerbasic Support

-------------------------------------------------------------------------
PowerBASIC, Inc.      | 800-780-7707 Sales | "We put the Power in Basic!"
316 Mid Valley Center | 831-659-8000 Voice | http://www.powerbasic.com



Mon, 28 Mar 2005 18:49:55 GMT  
 Redirection PB 3.2

Quote:

> Is there a way to determine whether output from a program is being
> redirected to a file?

> I make use out the STDOUT function supplied in the DOSUNIT.BAS file.

In PB 3.2 this can be achieved by calling int &h21, ax=&h4400:

'--------------------------------------------------------------->8---
' redir.bas (PB 3.2)
'--------------------------------------------------------------------

$COMPILE EXE

FUNCTION output_redirected () AS INTEGER
   ' returns TRUE or FALSE, or 1 on error
   ' (after Ralf Brown's Interrupt List, Release 61 (2000))

   ! mov  ax, &h4400
   ! mov  bx, 1           ; handle (1 = StdOut)
   ! stc                  ; set carry flag
   ! int  &h21

   ! jnc  redir_noerr     ; jump if carry flag isn't set
   ! mov  FUNCTION, 1     ; error
   EXIT FUNCTION

redir_noerr:
   ! test dx, &h8000
   ! jz   redir_exit      ; redirected to a file
   ! test dx, &h0004
   ! jnz  redir_exit      ; redirected to NUL
   ! mov  FUNCTION, 0     ; not redirected
   EXIT FUNCTION

redir_exit:
   ! mov  FUNCTION, -1
END FUNCTION

'-- Demo
$INCLUDE "pb32.inc"
DIM ofn AS INTEGER

StdOutLn "Hello World!"
ofn = FREEFILE
OPEN "redir.log" FOR APPEND AS #ofn
PRINT #ofn, "redirected:" output_redirected()
CLOSE #ofn
'--------------------------------------------------------------->8---

To see what the program does, call it the following ways:
   redir.exe
   redir.exe > re.txt
   redir.exe > nul

and then read the text in "redir.log".

Regards,
   Juergen

--
Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x].



Thu, 31 Mar 2005 02:00:57 GMT  
 Redirection PB 3.2
Many thanks!

Tom



Quote:

> > Is there a way to determine whether output from a program is being
> > redirected to a file?

> > I make use out the STDOUT function supplied in the DOSUNIT.BAS file.

> In PB 3.2 this can be achieved by calling int &h21, ax=&h4400:

> '--------------------------------------------------------------->8---
> ' redir.bas (PB 3.2)
> '--------------------------------------------------------------------

> $COMPILE EXE

> FUNCTION output_redirected () AS INTEGER
>    ' returns TRUE or FALSE, or 1 on error
>    ' (after Ralf Brown's Interrupt List, Release 61 (2000))

>    ! mov  ax, &h4400
>    ! mov  bx, 1           ; handle (1 = StdOut)
>    ! stc                  ; set carry flag
>    ! int  &h21

>    ! jnc  redir_noerr     ; jump if carry flag isn't set
>    ! mov  FUNCTION, 1     ; error
>    EXIT FUNCTION

> redir_noerr:
>    ! test dx, &h8000
>    ! jz   redir_exit      ; redirected to a file
>    ! test dx, &h0004
>    ! jnz  redir_exit      ; redirected to NUL
>    ! mov  FUNCTION, 0     ; not redirected
>    EXIT FUNCTION

> redir_exit:
>    ! mov  FUNCTION, -1
> END FUNCTION

> '-- Demo
> $INCLUDE "pb32.inc"
> DIM ofn AS INTEGER

> StdOutLn "Hello World!"
> ofn = FREEFILE
> OPEN "redir.log" FOR APPEND AS #ofn
> PRINT #ofn, "redirected:" output_redirected()
> CLOSE #ofn
> '--------------------------------------------------------------->8---

> To see what the program does, call it the following ways:
>    redir.exe
>    redir.exe > re.txt
>    redir.exe > nul

> and then read the text in "redir.log".

> Regards,
>    Juergen

> --
> Math problems? Call 1-800-[(10x)(13i)^2]-[sin(xy)/2.362x].



Fri, 01 Apr 2005 02:43:19 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Wipe file data information completly PB 3.2

2. Subs vs Functions PB 3.2

3. Printer Ready PB 3.2

4. Dynamic Arrays in PBU's PB 3.2

5. Dates PB 3.2

6. PB 3.2 program needed

7. PB 3.2.PB/Vision 2.0 Timerinstallcode.Shared Arrays

8. MX Lookup with PB/CC or PB/DLL

9. TCPADDR for PB/DLL & PB/CC

10. Info on new PB/CC and PB/DLL

11. Announcing the JazzAge COM Wizard for PB/DLL and PB/CC

12. animated characters, speech input/output in PB/DLL and PB/CC

 

 
Powered by phpBB® Forum Software