Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Replace CTTY in old .BTM

Oct
14
0
Pretty much what it says in the title. I'm rummaging through old .BTMs to see if any are of any use and I came across one that uses CTTY to redirect output to NUL. Other than adding >&NUL to the lines following it, is there any other way of replacing this function?

Thanks
 
I think redirection is the only way. This construction seemed to work in the latest version.

Code:
>&nul (
echo foo
netstat.exe
garbage
echoerr foo
)
 
aha! Yes, that should work. Thanks

I was trying to avoid putting >&Nul on every line and hadn't considered enclosing it all in brackets.
In the end, I decided the specific .BTM, wouldn't be of use to me, but it's nice to know the trick.
 
This also seems to work.

Code:
gosub subroutine >&NUL
echo subroutine returned
quit

:subroutine
echo foo
netstat.exe
garbage
echoerr foo
return
 
This also seems to work.

Code:
gosub subroutine >&NUL
echo subroutine returned
quit

:subroutine
echo foo
netstat.exe
garbage
echoerr foo
return

I prefer the second version. Grouping lines together with parentheses mashes them into a single virtual line, which can have unexpected side effects.
 
I prefer the second version. Grouping lines together with parentheses mashes them into a single virtual line, which can have unexpected side effects.
Yup. I never use parentheses that don't begin and end on the same line. Here's another that seems to work. You can even send some output to CON: (as I did below).

Code:
>&NUL do i=1 to 1
    echo foo > con:
    netstat.exe
    garbage
    echoerr foo
enddo

And (off-topic) you can do the likes of this which I use fairly often.

Code:
do | command | command [...]
...
enddo

I have a "TL" library routine (something like TASKLIST) with this line. %filter, which might be empty, is another pipe.

Code:
do i=0 to %lastline by 7 | d:\gnu\sort %sortargs %filter %@if[defined tail,| TAIL /N %tail,]

And I never use FOR. :smile:
 
Vince, I noticed that in some of your examples above you put redirection commands at the beginning of the line. The TCC help says that they should be placed at the end of the command line. I just experimented and discovered that they, indeed, can be placed at the beginning or the end. Is placing them at the beginning something that is common in other programming environments?
 
I know pretty little about other shells. You can do it in CMD and you can't in PowerShell (I only tried a few simple examples in each). I do it with multi-line DOs; maybe parentheses will help as they do with a one-line DO (didn't try).

Code:
v:\> do i=1 to 2 ( echo foo ) > nul
Usage : DO [n | FOREVER]

v:\> (do i=1 to 2 ( echo foo )) > nul

v:\>

That part of the help might be ancient.
 
Confirmed: with a multiline DO command the redirection works only if placed before the DO. Very interesting. I wonder how piping needs to be handled (but don't have time now to experiment).
 
Back
Top