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

Searching a command to immidiatly exit to shell

Started by ChaosNicro, 30 December 2014 - 10:30 AM
ChaosNicro #1
Posted 30 December 2014 - 11:30 AM
Hello everyone,

I have written CC programs in the past, but now I wish to create a program that I can actually post here.
For this I need to check for errors and want to exit to shell if there are any.

So What I am looking for is a typical eof/brake command.

I have heard that there are mutiple methods to exit to shell, I have also heard about an error() function.

Can someone please give me some insight on this?

Thanks in advance,
Nicro
KingofGamesYami #2
Posted 30 December 2014 - 01:34 PM
If you wish to exit a loop, you can use break.

If you wish to exit a function, you can use return.

If you wish to exit the program, you can use error*.

*note: If you give it no arguments, it'll simply exit. If you give it one argument (a string), it'll print that text along with the line number. If you give both arguments, a string and a number, the number will determine what to "blame". If you use 2, it'll blame the function that called it. If you use 0, it'll blame nobody.
ChaosNicro #3
Posted 30 December 2014 - 01:51 PM
That is all I needed, thank you.