aboutsummaryrefslogtreecommitdiffstats
path: root/docs/source/arduino/braces.rst
diff options
context:
space:
mode:
authorMarti Bolivar <mbolivar@mit.edu>2010-10-20 06:46:52 -0400
committerMarti Bolivar <mbolivar@mit.edu>2010-10-20 06:46:52 -0400
commit22ff1db8a76c7047b61a424ae1fa5f43697fcb34 (patch)
treebf722c8a5a6bd40e0b33fc4a425e0e5b8b9f4216 /docs/source/arduino/braces.rst
parentbac6548fe90b0721e191d68df2677beb4b15f60a (diff)
downloadlibrambutan-22ff1db8a76c7047b61a424ae1fa5f43697fcb34.tar.gz
librambutan-22ff1db8a76c7047b61a424ae1fa5f43697fcb34.zip
initial check-in of arduino docs in RST format (converted using wget+pandoc)
Diffstat (limited to 'docs/source/arduino/braces.rst')
-rw-r--r--docs/source/arduino/braces.rst113
1 files changed, 113 insertions, 0 deletions
diff --git a/docs/source/arduino/braces.rst b/docs/source/arduino/braces.rst
new file mode 100644
index 0000000..c7bd148
--- /dev/null
+++ b/docs/source/arduino/braces.rst
@@ -0,0 +1,113 @@
+.. _arduino-braces:
+
+{} Curly Braces
+===============
+
+Curly braces (also referred to as just "braces" or as "curly
+brackets") are a major part of the C programming language. They are
+used in several different constructs, outlined below, and this can
+sometimes be confusing for beginners.
+
+
+
+An opening curly brace "{" must always be followed by a closing
+curly brace "}". This is a condition that is often referred to as
+the braces being balanced. The Arduino IDE (integrated development
+environment) includes a convenient feature to check the balance of
+curly braces. Just select a brace, or even click the insertion
+point immediately following a brace, and its logical companion will
+be highlighted.
+
+
+
+At present this feature is slightly buggy as the IDE will often
+find (incorrectly) a brace in text that has been "commented out."
+
+
+
+Beginning programmers, and programmers coming to C from the BASIC
+language often find using braces confusing or daunting. After all,
+the same curly braces replace the RETURN statement in a subroutine
+(function), the ENDIF statement in a conditional and the NEXT
+statement in a FOR loop.
+
+
+
+Because the use of the curly brace is so varied, it is good
+programming practice to type the closing brace immediately after
+typing the opening brace when inserting a construct which requires
+curly braces. Then insert some carriage returns between your braces
+and begin inserting statements. Your braces, and your attitude,
+will never become unbalanced.
+
+
+
+Unbalanced braces can often lead to cryptic, impenetrable compiler
+errors that can sometimes be hard to track down in a large program.
+Because of their varied usages, braces are also incredibly
+important to the syntax of a program and moving a brace one or two
+lines will often dramatically affect the meaning of a program.
+
+
+
+**The main uses of curly braces**
+---------------------------------
+
+Functions
+---------
+
+::
+
+ void myfunction(datatype argument){
+ statements(s)
+ }
+
+
+
+Loops
+-----
+
+::
+
+ while (boolean expression)
+ {
+ statement(s)
+ }
+
+ do
+ {
+ statement(s)
+ } while (boolean expression);
+
+ for (initialisation; termination condition; incrementing expr)
+ {
+ statement(s)
+ }
+
+
+
+Conditional statements
+----------------------
+
+
+
+::
+
+ if (boolean expression)
+ {
+ statement(s)
+ }
+
+ else if (boolean expression)
+ {
+ statement(s)
+ }
+ else
+ {
+ statement(s)
+ }
+
+
+
+`Reference Home <http://arduino.cc/en/Reference/HomePage>`_
+