Re: [MSH] More Function
- From: "/\\/\\o\\/\\/" <no@xxxxxxxx>
- Date: Sun, 13 Nov 2005 23:51:38 +0100
Keith Hill wrote:
"/\/\o\/\/" <no@xxxxxxxx> wrote in message news:uXXUaxG6FHA.3136@xxxxxxxxxxxxxxxxxxxxxxxDid you check, if using the OpenText it will close after getting out of scope (and does this locking problem, only goes for the lastfile, or all files)?
thx, I have the Definition, it will show up normaly,only I can not find where it is defined. (in any profile file) so I got curious
But I can overrule it in my Profile, that is the Most important part ;-) (as it is a bit limited)
I wrote a new one that :
1) will NOT leave his StatusMessages around messing up the output
2) Will show the filePosition as Percentage
3) Supports the P Command that let's YOU give a number of lines
4) Supports the = Command that gives you the current Linenumber
5) Supports the F Command that skips to the next file.
6) Supports the -C argument to clear the Screen First.
Who is interested can find it here :
http://mow001.blogspot.com/2005/11/enhanced-more-function-for-msh.html
Nice work! This does point out one deficiency in the MSH script language: the lack of C#'s using statement for disposing disposable objects. The problem with your current implementation is that once you run it on a file you can no longer write to that file in the MSH session. You need to sprinkle some $fs.Close calls in your code everywhere where you exit the function e.g.:
"Q" {$fs.Close();$eof = $true;$Quit = $true}
A "using" block would allow you to grab the $fs variable and then no matter how the using block is exited (exception or normally) the variable will get disposed e.g.:
using ($fs = (get-item $file).OpenText()) { .... }
-- Keith
(as the SB does count the bytes also, you can also Add that value after every page written to get the value) than you can use the textreader.)
but as I did not care much about performance (viewing per page), I just took this solution to get the Position working (also had some Double newline problems, so maybe I should go back to the OpenText.).
but ofcourse, You right about the Closing of the Files, I should make that more of a habbit.(as i'm not a programmer I tend to be a bit careless with releasing, just counting on it to get out of scope.)especialy when I'm just reading.
Also the Ctrl-C I should handle myself I think to get this done. (does I ugly exit now)
also nice was the difference between the ReadKey of Console and of the $host Object.(in handeling shift / control)
also I'm still a bit finding my "style" in MSH and expect to change it for the coming time,i never intended it to be production quality, but keeping files locked after the function is gone out of scope is not good, I will look into that.
thx for the remark, did not see this yet.
gr /\/\o\/\/
.
- References:
- [msh] $args.lenght or $args.Count and other $args oddities.
- From: /\\/\\o\\/\\/
- [MSH] More Function
- From: /\\/\\o\\/\\/
- Re: [MSH] More Function
- From: Jacques Barathon [MS]
- Re: [MSH] More Function
- From: /\\/\\o\\/\\/
- Re: [MSH] More Function
- From: Keith Hill
- [msh] $args.lenght or $args.Count and other $args oddities.
- Prev by Date: RE: Adding Groups on the basis of text in a VBScript
- Next by Date: Re: Copy file to multiple remote servers
- Previous by thread: Re: [MSH] More Function
- Next by thread: How to find enabled users who logged on in the last six months
- Index(es):
Relevant Pages
|