Difference between revisions of "Shell.exit"

From ComputerCraft Wiki
Jump to: navigation, search
m (Expanded)
 
(One intermediate revision by one other user not shown)
Line 5: Line 5:
 
|api=shell
 
|api=shell
 
|addon=ComputerCraft
 
|addon=ComputerCraft
|desc=Exits the current program (or shell if no program is open).
+
|desc=Causes the [[CraftOS|shell]] to terminate after the current script has finished execution, which will generally lead to the system shutting down. Note that it does ''not'' cause the currently executing script to exit. When using multiple tabs via [[multishell]], will only halt the shell in the current tab. Compare [[os.shutdown|os.shutdown()]], which causes an ''immediate'' system shutdown.
 
|examples=
 
|examples=
 
{{Example
 
{{Example
|desc=Exits the program.
+
|desc=Current shell will exit once this code has finished execution.
|code= [[print]]("Prepare for program termination...")
+
|code= shell.exit()
  [[sleep]](3)
+
print("Press any key to exit shell...")
'''shell.exit()'''
+
  os.pullEvent("char")
 
}}
 
}}
 
}}
 
}}
  
 
[[Category:API_Functions]]
 
[[Category:API_Functions]]

Latest revision as of 01:56, 22 January 2015


Grid Redstone.png  Function shell.exit
Causes the shell to terminate after the current script has finished execution, which will generally lead to the system shutting down. Note that it does not cause the currently executing script to exit. When using multiple tabs via multishell, will only halt the shell in the current tab. Compare os.shutdown(), which causes an immediate system shutdown.
Syntax shell.exit()
Returns None
Part of ComputerCraft
API shell

Examples

Grid paper.png  Example
Current shell will exit once this code has finished execution.
Code
shell.exit()
print("Press any key to exit shell...")
os.pullEvent("char")