[comp.sys.ibm.pc] more.com question

cjdb@sphinx.UUCP (02/24/87)

I just downloaded the recently posted more.com. When I type filename |
more.com, I get more without an indication of how much of the rest of
the file there is to be typed. When I type | more filename, I get
"Invalid number of parameters" from PC-DOS 3.2, then the file is
typed, and more _does_ indicate how much of the file is left. I'm not
up to thinking this through. Can someone tell me what's going on?


(Note: DOS's more I have renamed, so I'm not inadvertently using it at
any point.)

-- 
Charles Blair   			    ..!ihnp4!gargoyle!sphinx!cjdb
The University of Chicago		          PMRCJDB@UCHIMVS1.Bitnet

madd@bucsb.bu.edu.UUCP (02/27/87)

In article <1172@sphinx.UChicago.UUCP> cjdb@sphinx.UChicago.UUCP (Charles Blair) writes:
>I just downloaded the recently posted more.com. When I type filename |
>more.com, I get more without an indication of how much of the rest of
>the file there is to be typed. When I type | more filename, I get
>"Invalid number of parameters" from PC-DOS 3.2, then the file is
>typed, and more _does_ indicate how much of the file is left. I'm not
>up to thinking this through. Can someone tell me what's going on?

Sure.  I wrote more.com, so I suppose I'm the best authority on why it
does that.  First, there is no reasonable way to find out how big the
stream of information you are streaming to more.com is when more.com
is the trailing end of a pipe.  I think I could kludge it by finding
out what the name of the temporary file is that DOS uses when piping,
but this is not a good idea, so I didn't do it.  If you try the UNIX
"more" or "less" programs, you'll notice that they, too, do not give
you the size/percentage through of a file, for the same reason.  I
suppose I could have told you how many characters through the file you
have gone (that is kept track of anyway, I believe, or could be with
little effort), but I chose not to.  The more.com utility was designed
to be used as a better "type" command.  The piping function makes it
even more useful, but there are limitations (like not knowing the
total size of the input).

When you type "type filename | more" DOS puts the output from "type
filename" into a temporary file.  When "type" is done, DOS activates
"more" and starts feeding it the lines from the temporary file.

When you type "type | more filename", DOS attempts to start up the
"type" command, finds that it has no argument, and then activates
"more.com".  More.com assumes that if it has an argument, you want to
list out that argument, and if there's no argument, then you are
using the standard input.  Therefore, more.com opens the file and
starts dumping it to the screen, but not before DOS gives you an
error message.

The proper way to list a file with more.com is "more filename".  This
is NOT how the MS-DOS more program works, but IS how the UNIX more and
less commands work, which is what I modelled mine after.

I hope this has adequately answered your question.  If you have more
questions or comments about MORE.COM, please email me at one of the
addresses below.  Please provide a good, solid path, preferably one
through allegra or some other major site, but not harvard.  You see,
harvard's mailer hates me.  ARPA addresses are welcomed.

Miscellaneous note:

The last posted version of MORE.COM is v1.4.  If you haven't seen it
yet, email me and I'll email it out.  Note that there is one bug that
has been found in v1.4:  it line wraps at column 79 and not column 80.
This has been fixed, but I will not post the fix until I finish some
major additions.  It's not usually serious except with some heavily
formatted files, and only affects the way the files appear onscreen.

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
                   - Jim Frost * The Madd Hacker -
UUCP:  ..!harvard!bu-cs!bucsb!madd | ARPANET: madd@bucsb.bu.edu
CSNET: madd%bucsb@bu-cs            | BITNET:  cscc71c@bostonu
-------------------------------+---+------------------------------------
"Oh beer, oh beer." -- Me      |      [=(BEER) <- Bud the Beer (cheers!)

dmt@mtunb.UUCP (02/27/87)

In article <1172@sphinx.UChicago.UUCP> cjdb@sphinx.UChicago.UUCP (Charles Blair) writes:
>
>I just downloaded the recently posted more.com. When I type filename |
>more.com, I get more without an indication of how much of the rest of
>the file there is to be typed. 
	When MORE knows the file it's working with, it can tell its size
	and calculate the percent left.  However, if it's just reading
	standard input (e.g.- from a pipe as you describe), if has no idea
	where the file ends so it can't estimate percent complete.  At least
	it's smart enough not to try.

>When I type | more filename, I get
>"Invalid number of parameters" from PC-DOS 3.2, then the file is
>typed, and more _does_ indicate how much of the file is left.
	What happens here is interesting:

   -	First, DOS runs TYPE with no arguments.  The result is the error
	message, since TYPE _must_ have a filename argument.

   -	Next, DOS runs MORE with the filename argument and _also_ STDIN.
	(Of course, STDIN is null, because TYPE failed.)  The messages
	you get here are from MORE running _with_ a filename argument,
	so it can tell the size of the file.

Hope this helps.
+---------------------------------------------------------------+
|    Dave Tutelman						|
|    Physical - AT&T  -  Lincroft, NJ				|
|    Logical -  ...ihnp4!mtuxo!mtunb!dmt			|
|    Audible -  (201) 576 2442					|
+---------------------------------------------------------------+