This is a read-only snapshot of the ComputerCraft forums, taken in April 2020.
graywolf69's profile picture

'End' expected to close 'While'

Started by graywolf69, 30 September 2014 - 11:40 PM
graywolf69 #1
Posted 01 October 2014 - 01:40 AM
I was testing out my new program and got this error message when I tried to run it:

bios:336 [string "ccts"]:59: 'end' expected (to close 'while' at line 2)

I checked the program, and all the end's looked in their right places, I'm stumped. Can someone tell me how to fix this? (ignore my placeholders of INSERT, that was for easy find and replace one i got computer ids)

file: http://pastebin.com/UnVkVL8v

THANKS!
-graywolf69
Dragon53535 #2
Posted 01 October 2014 - 02:05 AM
Your While loop at line 2 does not have an end. And you're going to get a lot more errors from the program. Your if statements cannot have an end if there's an else/elseif after it such as

if a == z then
  yay()
end --#Ends the if statement, and allows no else/elseif's
else --# Or else what? according to the program you've got nothing to do first.
  nooo()
end
To properly do this and have it work you would put it like this

if a == z then
  yay()
else
  nooo()
end
Edited on 01 October 2014 - 12:05 AM
graywolf69 #3
Posted 01 October 2014 - 04:43 AM
Lol! Can't believe I didn't remember that thanks so much!
Evil_Bengt #4
Posted 03 October 2014 - 02:58 PM
Maybe you've fixed the paste by now but while does seem to have an end so I can't say what's wrong…
theoriginalbit #5
Posted 03 October 2014 - 03:02 PM
Maybe you've fixed the paste by now but while does seem to have an end so I can't say what's wrong…
chances are they fixed the paste, because based on their answer they definitely know what was wrong and would have fixed it
Dragon53535 #6
Posted 03 October 2014 - 11:49 PM
Yes he did, however as a suggestion to him if he reads this again, your indentation is off by one since you should normally indent everything inside of a while loop :P/>
theoriginalbit #7
Posted 04 October 2014 - 01:58 AM
Yes he did, however as a suggestion to him if he reads this again, your indentation is off by one since you should normally indent everything inside of a while loop :P/>
Indenting is a preference, not a requirement
Dragon53535 #8
Posted 04 October 2014 - 05:57 AM
Indenting is a preference, not a requirement
Yes however he had the rest indented so i was informing him that to help realize those errors, while loops would need indentation for everything within if he's trying to indent