struttshumming
-
Total Posts
:
8
- Scores: 0
-
Reward points
:
0
- Joined: 3/14/2008
-
Status: offline
|
A question about functions...
Wednesday, September 24, 2008 10:52 PM
( permalink)
Hi There, I have been trying to put together a simple function that takes in 2 argumnets. I then want to split them into arrays and try to return a given element of each. here is my code: $StrOne = "1,2,3,4" $StrTwo = "A,B,C,D" function DoStuff {param ([string]$Numbers,[string]$Letters) $ArrNum = $Numbers.split(",") $ArrLet = $Letters.split(",") #write-host $ArrLet[0] write-host $ArrNum[3] } DoStuff($StrOne,$StrTwo) But...i dont understand how it is returning both elements when (4 & A) when the letters array split is commented out. Where have i gone wrong?
|
|
|
|
dm_4ever
-
Total Posts
:
3687
- Scores: 82
-
Reward points
:
0
- Joined: 6/29/2006
- Location: Orange County, California
-
Status: offline
|
RE: A question about functions...
Thursday, September 25, 2008 3:09 AM
( permalink)
Its due to the way you are passing the values...it is slightly different that you would with VBScript $StrOne = "1,2,3,4" $StrTwo = "A,B,C,D" function DoStuff {param ([string]$Numbers,[string]$Letters) $ArrNum = $Numbers.split(",") $ArrLet = $Letters.split(",") #write-host $ArrLet[0] write-host $ArrNum[3] } DoStuff $StrOne $StrTwo
|
|
|
|
struttshumming
-
Total Posts
:
8
- Scores: 0
-
Reward points
:
0
- Joined: 3/14/2008
-
Status: offline
|
RE: A question about functions...
Thursday, October 09, 2008 5:27 AM
( permalink)
cool, thanks for letting me know:)
|
|
|
|