ang3lus
asked on
Printing on one line
Hi
I calculate run time of script then depend on this time i create for loop to display progress
for example if execution time 21 seconds the script will print this shape <> 21 times
<><><><><><><><><><><
my problem is the printing display like this
<
>
<
>
<
>
<
>
<
>
<
>
<
>
<
>
<
>
<
>
How i can avoid line breaking
I calculate run time of script then depend on this time i create for loop to display progress
for example if execution time 21 seconds the script will print this shape <> 21 times
<><><><><><><><><><><
my problem is the printing display like this
<
>
<
>
<
>
<
>
<
>
<
>
<
>
<
>
<
>
<
>
How i can avoid line breaking
$time = 9;
for ($i=1; $i -le $time; $i++) {
$sh1= "<"
if($i % 2 -eq 0)
{
$sh2 = ">"
}
$sh1
$sh2
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You can also add in a sleep timer to make it pop in 1 per second and also print out a blank at the end so your prompt doesn't pop up at the end of your <><><><><>.
It would look as follows:
It would look as follows:
$time = 9;
for ($i=1; $i -le $time; $i++)
{
$sh1= "<"
if($i % 2 -eq 0)
{
$sh2 = ">"
}
start-sleep -s 1
Write-Host -NoNewline $sh1
Write-Host -NoNewline $sh2
}
Write-host
ASKER
It solved my problem