Why is Break not breaking in powershell

  Kiến thức lập trình

For some reason my script:

Clear-Host
Write-Host Welcome to QuickScripter! Quickly script files! Type run to start, clear to restart, and exit to exit and remove script.
if (Test-Path .script.ps1) {
Remove-Item .script.ps1
}
New-Item .scripty.ps1 -ErrorAction SilentlyContinue
function Enter-Loop {
$in = Read-Host
if ($in -eq "run")
    {.script.ps1}
elseif ($in -eq "exit")
    {Remove-Item .script.ps1 ; Clear-Host; exit}
elseif ($in -eq "clear")
    {Clear-Content .script.ps1}
elseif ($in -eq "load") {
    $i = 0
    $a = 0
    :loop while (true) {
        if (Test-Path ./tape/$i) {
            Write-Host $i
            $a++
        } else {
            break loop
        }
    }
    Write-Host Choose a script to load:
    $i = 0
    for ($i -lt $a) {
        Write-Host $i
    }
    $t = Read-Host -Prompt "Tape:"
    if ($t -gt $a) {
        zenity --error --text="404: This tape is missing"
    }
    else {
        Copy-Item ./tape/$t ./script.ps1
    }
elseif ($in -eq "record") {
    $i = 0
    while (true) {
        if(Test-Path ./tape/$i){
            $i++
        }
        else {
            New-Item -Path ./tape/ -Name $i
            Set-Content ./tape/$i -Value ./script.ps1
        }
    }
}
}
else
    {Add-Content -Path .script.ps1 -Value $in }}
while(1 -eq 1){Enter-Loop}

doesn’t break.
Why?

A lot
For it to not loop 0
So how do i get it to not forever loop at the load part? And record doesn’t work.
And stackoverflow doesn’t like my code so heres gibberish:
dfghdkrgjrlihjtilhjtlihjdfhlifjhlifhjfdhjrtdophidrtpoymtroyimrtoi[nmu

New contributor

leon is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.

LEAVE A COMMENT