Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
184_notes:troubleshooting [2022/04/20 16:13] – woodsna1 | 184_notes:troubleshooting [2022/05/06 22:06] (current) – [Math] woodsna1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Coding: When it all Goes Wrong ====== | ====== Coding: When it all Goes Wrong ====== | ||
- | A programming project isn't complete without an error that seems impossible to fix. Glowscript' | + | A programming project isn't complete without an error that seems impossible to fix. Glowscript' |
===== Debugging ===== | ===== Debugging ===== | ||
Often, something you've written isn't doing what you expect it to. The best way to track these issues down in Glowscript is using print() statements. Pick a value, and print it out. Then check if the printed value matches what you expect. Try a few if you're having trouble tracking down an error. | Often, something you've written isn't doing what you expect it to. The best way to track these issues down in Glowscript is using print() statements. Pick a value, and print it out. Then check if the printed value matches what you expect. Try a few if you're having trouble tracking down an error. | ||
+ | |||
+ | Another good strategy is to comment out code that you suspect is causing an error, then add it back in line-by-line until you find the source of the error. | ||
Sometimes, the issue is with the way your code is written (syntax). These cases can be particularly hard to track down. | Sometimes, the issue is with the way your code is written (syntax). These cases can be particularly hard to track down. | ||
Line 26: | Line 28: | ||
</ | </ | ||
=== Divide by Zero === | === Divide by Zero === | ||
- | If your code contains division by 0, you may get a confusing error message. Double-check that variables are properly initialized, | + | If your code contains division by 0, you may get a confusing error message. Double-check that variables are properly initialized, |
==== Loops ==== | ==== Loops ==== | ||
If the conditional initially evaluates to False, the loop will never execute. | If the conditional initially evaluates to False, the loop will never execute. |