Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Newbie - Creating a increasing variable- Maybe an array

$
0
0

Not sure how to ask this question.

I want a loop where I enter in numbers for the same 3 questions until I end the loop by entering in a key word such as "end"

Then I will create another loop that will display all the numbers I put in for the 3 questions, in the order in which I entered them.

the way I have done this before was to create an array and just in crease the array number as I go through the loop assigning the value entered in to the new array name. Then play it back just by increasing they array number.

Here is a simple outline of what I was thinking " syntax is not correct as I do not know how it should be done"

Loop until input = end

$I = $I+1

$array1($I) = read-host "enter number $I for question 1, type end to end loop"  #this should assign $array(x) a value where x increases until the loop ends

$array2($I) = read-host "enter number $I for question 2,

$array3($I) = read-host "enter number $I for question 3,

To play it back I was thinking something like this:

For ($L = 0; $L - lt $I; $L++)

 "array1  = $array1($L)"

 "array2  = $array2($L)"

 "array3  = $array3($L)"

Not sure if this is doable somehow.

Thanks

Jim



Viewing all articles
Browse latest Browse all 21975

Trending Articles