![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| Guest | Lenght property What am I missing here? Would ".lenght" not give me the number of elements? PS C:\> echo "1" > test.1 PS C:\> echo "2" >> test.1 PS C:\> gc test.1 1 2 PS C:\> (gc test.1).lenght PS C:\> From the PSH user guide: "Get-Content already treats the data read from the file as an array, with one element per line of file content. You can confirm this by checking the Length of the returned content: " Marco |
My System Specs![]() |
| | #2 (permalink) |
| Guest | Re: Lenght property On Tue, 7 Nov 2006 11:35:02 -0400, Marco Shaw wrote: > What am I missing here? Would ".lenght" not give me the number of elements? > > PS C:\> echo "1" > test.1 > PS C:\> echo "2" >> test.1 > PS C:\> gc test.1 > 1 > 2 > PS C:\> (gc test.1).lenght > PS C:\> > > From the PSH user guide: > "Get-Content already treats the data read from the file as an array, with > one element per line of file content. You can confirm this by checking the > Length of the returned content: " > > > > Marco It does. You just have a typo: PS E:\temp> echo 1 >test.1 PS E:\temp> echo 2 >>test.1 PS E:\temp> gc test.1 1 2 PS E:\temp> (gc test.1).length 2 PS E:\temp> -- Jeffery Hicks - www.ScriptingAnswers.com SAPIEN Technologies - Scripting, Simplified. www.SAPIEN.com Scripting books: www.SAPIENPress.com |
My System Specs![]() |
| | #3 (permalink) |
| Guest | Re: Lenght property > It does. You just have a typo: *sigh* Pardon my French... If I had of been using PrimalScript... ;-) |
My System Specs![]() |
| | #4 (permalink) |
| Guest | Re: Lenght property Marco Shaw wrote: > > It does. You just have a typo: > > *sigh* Pardon my French... > > If I had of been using PrimalScript... ;-) I consider "Length" to be a bit hard to type so I usually go with "Count" alias property for accessing Length property. $a = @(1,2,3) ,$a | gm TypeName: System.Object[] Name MemberType Definition ---- ---------- ---------- Count AliasProperty Count = Length Not only Count looks more intuitive in your script, it's less error prone than Lenght |
My System Specs![]() |
| | #5 (permalink) |
| Guest | Re: Lenght property > ,$a | gm Hmmm... How is "$a|gm" different from ",$a|gm"? I see it gives different results. Not sure what "," does here... > Not only Count looks more intuitive in your script, > it's less error prone than Lenght See, you did it too... ;-) |
My System Specs![]() |
| | #6 (permalink) |
| Guest | Re: Lenght property Marco Shaw wrote: > > ,$a | gm > > Hmmm... How is "$a|gm" different from ",$a|gm"? I see it gives different > results. Not sure what "," does here... "Get-Member" cmdlet takes all the types and displays only a distinct type information. Since "$a" contains values of type integers, doing "$a | gm" would result in displaying member information for "Int32". ",$a | gm" uhm. i forgot exactly how it worked but it does about the same job as "gm -inputobject $a" > > > Not only Count looks more intuitive in your script, > > it's less error prone than Lenght > > See, you did it too... ;-) Bah! That was certainly unintentional. ![]() |
My System Specs![]() |
| | #7 (permalink) |
| Guest | Re: Lenght property Hi Sung > ",$a | gm" uhm. i forgot exactly how it worked but it does about the > same job as > "gm -inputobject $a" if you write $a=1,2,3 $a | gm then PS takes each object (in this case integers) out of the $a array and places it in the pipe. Hence gm gets 3 integers through the pipe. If on the other hand you write this: ,$a | gm then you actually pass an array of an integer array. In this case PS passes the content of the array in the same way as before, but now the content of the "outer array" is the int array so gm gets one array of integers. hth Max |
My System Specs![]() |
| | #8 (permalink) |
| Guest | Re: Lenght property "Sung M Kim" <DontBotherMeWithSpam@gmail.com> wrote in message news:1162919122.719348.161590@f16g2000cwb.googlegroups.com... > Not only Count looks more intuitive in your script, > it's less error prone than Lenght htat's hte truht. ![]() |
My System Specs![]() |
| | #9 (permalink) |
| Guest | Re: Lenght property Ahh, it makes me feel very good that I'm not the only one on earth who suffers from Lenght! ![]() -- greetings dreeschkind "Alex K. Angelopoulos [MVP]" wrote: > > "Sung M Kim" <DontBotherMeWithSpam@gmail.com> wrote in message > news:1162919122.719348.161590@f16g2000cwb.googlegroups.com... > > > Not only Count looks more intuitive in your script, > > it's less error prone than Lenght > > htat's hte truht. ![]() > > > |
My System Specs![]() |
| | #10 (permalink) |
| Guest | Re: Lenght property > htat's hte truht Did you konw taht an epitmtxenareoin sowhs taht a txet is rabeldae if olny fsrit and lsat ltertes of wodrs are in oderr ? :-) -- Jean - JMST Belgium |
My System Specs![]() |
![]() |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How do I use the property of a property? | John Vottero | PowerShell | 2 | 07-28-2008 11:18 AM |
| Changing the lenght of one picture? | Jen W. | Vista music pictures video | 0 | 06-24-2008 10:08 PM |
| Use my custom TypeDescriptor to obtains default Value on property inXAML Property Editor of Visual Studio 2008 | azerty | Avalon | 0 | 04-14-2008 06:14 AM |
| Value under the CPU property? | Cyberstorme | PowerShell | 2 | 01-10-2008 12:10 PM |