Permalink
Browse files

fixing breaks

  • Loading branch information...
1 parent 400b01c commit 040d17c74c77c8a31becdd5d76c1668775de4e4b @mhenke committed Jul 4, 2011
Showing with 86 additions and 86 deletions.
  1. +82 −82 cfml100mins.markdown
  2. +4 −4 readme.markdown
View
164 cfml100mins.markdown
@@ -26,9 +26,9 @@ And you want to learn CFML so here goes!
## 1. Syntax
-There are two ways to write CFML code. You can use tag or script syntax. For the examples, please focus on one or the other so this tutorial is not confusing. CFML includes a set of instructions you use in pages. You will write one or more instructions in a file then run the file through a CFML engine. Three CFML instructions we will use in this tutorial are 'CFSET', 'CFOUTPUT', and 'CFDUMP'. 'CFSET' is used to create a variable and assign it a value. Also 'CFSET' is used to call methods. 'CFOUTPUT' displays a variable's value. 'CFDUMP' is used to display the contents of simple and complex variables, objects, components, user-defined functions, and other elements.
+There are two ways to write CFML code. You can use tag or script syntax. For the examples, please focus on one or the other so this tutorial is not confusing. CFML includes a set of instructions you use in pages. You will write one or more instructions in a file then run the file through a CFML engine. Three CFML instructions we will use in this tutorial are "CFSET", "CFOUTPUT", and "CFDUMP". "CFSET" is used to create a variable and assign it a value. Also "CFSET" is used to call methods. "CFOUTPUT" displays a variable's value. "CFDUMP" is used to display the contents of simple and complex variables, objects, components, user-defined functions, and other elements.
-We might have a file named 'myprogram.cfm' and 'Sample.cfc' like this:
+We might have a file named _myprogram.cfm_ and _Sample.cfc_ like this:
### Tag Syntax
@@ -70,7 +70,7 @@ component {
}
```
-For the script example, 'myprogram.cfm' and 'Sample.cfc' would have beginning/closing '<cfscript>' tags around the instructions.
+For the script example, ```myprogram.cfm``` and ```Sample.cfc``` would have beginning/closing ```<cfscript>``` tags around the instructions.
### PHP Syntax
@@ -127,7 +127,7 @@ a = #a#<br/>
b = #b#<br/>
<cfset c = 15 + a + b />
c = #c#<br/>
-<cfset b = c - a />
+<cfset b = c * a />
b = #b#<br/>
<cfset d = "Hello, " />
d = #d#<br/>
@@ -144,10 +144,10 @@ b = 10 + 5;
writeOutput("b = #b#<br/>");
c = 15 + a + b;
writeOutput("c = #c#<br/>");
-b = c - a;
+b = c * a;
writeOutput("b = #b#<br/>");
d = "Hello, ";
-writeOutput("d = #d#<br/>");
+writeOutput('d = #d#<br/>");
</cfscript>
```
@@ -189,11 +189,11 @@ writeOutput("b = #b#<br/>");
### Components
-In CFML, a ColdFusion component (CFC) file contains data and methods. Components are a building blocks for objects. Objects know information, called 'attributes', and can do actions, called 'methods'. In ColdFusion the 'cffunction' tag is used to define methods within a CFC.
+In CFML, a ColdFusion component (CFC) file contains data and methods. Components are a building blocks for objects. Objects know information, called "attributes", and can do actions, called "methods". In ColdFusion the "cffunction" tag is used to define methods within a CFC.
For an example of an object, think about you as a human being. You have attributes like height, weight, and eye color. You have methods like walk, run, wash dishes, and daydream. Different kinds of objects have different attributes and methods. In the next sections we'll look at a few specific instructions in CFML.
-In CFML we define an object using the 'cfcomponent' instruction and save the file as '.cfc'. Here's an example defining the object type 'PersonalChef.cfc':
+In CFML we define an object using the "cfcomponent" instruction and save the file as _.cfc_. Here's an example defining the object type _PersonalChef.cfc_:
#### Tag
@@ -213,7 +213,7 @@ component {
### Methods
-Inside the CFC we usually define one or more methods using the 'cffunction' instruction like this:
+Inside the CFC we usually define one or more methods using the "cffunction" instruction like this:
#### Tag
@@ -235,9 +235,9 @@ component {
}
```
-Inside the 'cffunction' instruction we'd put the code for how the chef should make the toast.
+Inside the "cffunction" instruction we'd put the code for how the chef should make the toast.
-A 'class' is an abstract idea, it defines what all objects of that type can know and do. Think of the chair you're sitting in. Its not an abstract chair, it is an actual chair. We'd call this actual chair an 'instance'. It is a *realization* of the idea chair. It has measurable attributes like height, color, weight. The class chair, on the other hand, is *abstract*. The class's weight, color, and size we can't determine them ahead of time.
+A "class" is an abstract idea, it defines what all objects of that type can know and do. Think of the chair you're sitting in. Its not an abstract chair, it is an actual chair. We'd call this actual chair an "instance". It is a *realization* of the idea chair. It has measurable attributes like height, color, weight. The class chair, on the other hand, is *abstract*. The class's weight, color, and size we can't determine them ahead of time.
Once we define a class, we create an instance of that class like this:
@@ -253,13 +253,13 @@ Once we define a class, we create an instance of that class like this:
frank = New PersonalChef();
```
-We're calling the 'New' instruction on the class 'PersonalChef' and storing it into the variable named 'frank'. Once we have the instance, we can set or get its attributes and call its methods. Methods are called by using this syntax: 'object.method_name()'. So if you have a person named 'frank' you would tell him to make toast by calling 'frank.makeToast()'.
+We're calling the **New** instruction on the class **PersonalChef** and storing it into the variable named _frank_. Once we have the instance, we can set or get its attributes and call its methods. Methods are called by using this syntax: "object.method_name()". So if you have a person named "frank" you would tell him to make toast by calling ```frank.makeToast()```.
-The 'New' instruction creates a new instance of the object and calls it's init () method (if existing). Any arguments supplied to the object will be passed to the init () method. The init () method should return the object instance using '<cfreturn this />' in order to have the same expected behavior as the 'CreateObject' instruction. If no init () method exists, the object will be returned normally.
+The **New** instruction creates a new instance of the object and calls it's ```init()``` method (if existing). Any arguments supplied to the object will be passed to the ```init()``` method. The ```init()``` method should return the object instance using ```<cfreturn this />``` in order to have the same expected behavior as the **CreateObject** instruction. If no init () method exists, the object will be returned normally.
### Method Parameters
-Sometimes methods take one or more *parameters* telling them **how** to do what they're suppose to **do**. For instance, I might call 'frank.makeToast('burned')' for him to burn my toast. Or maybe he has another method where I call 'frank.makebreakfast("toast","eggs")' for him to make both toast and eggs. Parameters can be numbers, strings, or any kind of object. When a method takes a parameter we use the 'cfargument' instruction, it'll look like this:
+Sometimes methods take one or more *parameters* telling them **how** to do what they're suppose to **do**. For instance, I might call ```frank.makeToast("burned")``` for him to burn my toast. Or maybe he has another method where I call ```frank.makebreakfast("toast","eggs")``` for him to make both toast and eggs. Parameters can be numbers, strings, or any kind of object. When a method takes a parameter we use the ```cfargument``` instruction, it'll look like this:
#### Tag
@@ -282,15 +282,15 @@ component {
}
```
-The method is requiring us to pass in a 'color' telling it how to do the method 'makeToast'.
+The method is requiring us to pass in a "color" telling it how to do the method "makeToast".
### Return Value
-In CFML, every time you call a method you won't necessarily get a value back. By default, a CFML method returns *nothing*. We'll talk about *nothing* and 'null' in the last section of "CFML in 100 minutes". If you called 'makeToast' method above like '<cfset result = frank.makeToast('burned') />' or 'set result = frank.makeToast('burned');', and tried to output 'result' you should have seen 'Variable RESULT is undefined'.
+In CFML, every time you call a method you won't necessarily get a value back. By default, a CFML method returns *nothing*. We'll talk about *nothing* and null" in the last section of "CFML in 100 minutes". If you called "makeToast" method above like ```<cfset result = frank.makeToast("burned") />``` or ```set result = frank.makeToast("burned");```, and tried to output "result" you should have seen "Variable RESULT is undefined".
-To return data, we use 'cfreturn' to instruct the method to return a 'value'. Since that wasn't in the last instruction before the ending 'cffunction' in your 'makeToast' method, you received *nothing* and tried to putting that into the 'result' variable.
+To return data, we use "cfreturn" to instruct the method to return a "value". Since that wasn't in the last instruction before the ending "cffunction" in your "makeToast" method, you received *nothing* and tried to putting that into the "result" variable.
-For the purposes of our next section I'm going to return the chef instance itself from the method. If you wanted to picture the metaphor, imagine you are looking at your chef 'frank'. You say, "Frank, go make my toast", he tells you he's making the toast, goes to make it, then comes back to you to receive more instructions. He's **returning himself** to you. Here's how we implement it in code:
+For the purposes of our next section I"m going to return the chef instance itself from the method. If you wanted to picture the metaphor, imagine you are looking at your chef "frank". You say, "Frank, go make my toast", he tells you he's making the toast, goes to make it, then comes back to you to receive more instructions. He's **returning himself** to you. Here's how we implement it in code:
#### Tag
@@ -317,20 +317,20 @@ component {
## 4. Strings
-In CFML a string is defined as a quote ( "'" ) followed by zero or more letters, numbers, or symbols and followed by another quote ( "'" ). Some simple strings would be **hello** or **This sentence is a string!**. Strings can be anything from '', the empty string, to really long sets of text. This whole tutorial, for instance, is stored in a string. Strings have a few important instructions that we'll use.
+In CFML a string is defined as a quote ( """ ) followed by zero or more letters, numbers, or symbols and followed by another quote ( """ ). Some simple strings would be **hello** or **This sentence is a string!**. Strings can be anything from "", the empty string, to really long sets of text. This whole tutorial, for instance, is stored in a string. Strings have a few important instructions that we'll use.
### Len
-* Call 'Len' on a string to get back the number of characters in the string. For instance 'Len("Hello")' would give you back '5'.
+* Call "Len" on a string to get back the number of characters in the string. For instance "Len("Hello")" would give you back "5".
### Replace
-* The 'Replace' instruction replaces occurrences of **substring1** in a string with **substring2**, in a specified scope. The search is case sensitive and the scope default is one. For instance, **Replace("Hello", "e", "")** would give you back **hllo** after replacing the *first* occurrence of **e**, or **Replace("Good Morning!", "o", "e", "All")** would give you **Geed Merning!**
+* The "Replace" instruction replaces occurrences of **substring1** in a string with **substring2**, in a specified scope. The search is case sensitive and the scope default is one. For instance, **Replace("Hello", "e", "")** would give you back **hllo** after replacing the *first* occurrence of **e**, or **Replace("Good Morning!", "o", "e", "All")** would give you **Geed Merning!**
### RemoveChars
-* Call 'RemoveChars' to remove characters from a string. For instance, 'RemoveChars("hello bob", 2, 5)' would give you back **hbob**.
+* Call "RemoveChars" to remove characters from a string. For instance, "RemoveChars("hello bob", 2, 5)" would give you back **hbob**.
### Mid
-* The 'mid' instruction extracts a substring from a string. For instance, I could call 'Mid("Welcome to CFML Jumpstart",4,12)' and it would give you back: 'come to CFML'.
+* The "mid" instruction extracts a substring from a string. For instance, I could call "Mid("Welcome to CFML Jumpstart",4,12)" and it would give you back: "come to CFML".
Experiment with the following samples in a CFML file.
@@ -380,7 +380,7 @@ writeOutput(t4[2]);
</cfscript>
```
-The numbers inside the '[]' brackets specify which item of the array you want pulled out. They're numbered starting with 1. So the first example pulls out the '2' array item. This 't4' array contains position '1', the beginning of the list, up to position '4', the ending of the array.
+The numbers inside the "[]" brackets specify which item of the array you want pulled out. They're numbered starting with 1. So the first example pulls out the "2" array item. This "t4" array contains position "1", the beginning of the list, up to position "4", the ending of the array.
### Combining Strings and Variables
@@ -392,11 +392,11 @@ When we put that into the CFML file, it just spits back the same string. If we w
What we need to do is combine a variable with the string. There are two ways to do that. The first approach is called *string concatenation* which is basically just adding strings together:
-In the first line we setup a variable to hold the day of the week. Then we'll printed the string *Happy* combined with the value of the variable 'today' and the string *!*. You might be thinking, "What was the point of that since we still wrote *Saturday* in the first line?" Ok, well, if you were writing a real program you'd use CFMLs built-in date instructions like this:
+In the first line we setup a variable to hold the day of the week. Then we'll printed the string *Happy* combined with the value of the variable "today" and the string *!*. You might be thinking, "What was the point of that since we still wrote *Saturday* in the first line?" Ok, well, if you were writing a real program you'd use CFMLs built-in date instructions like this:
-'today = DayOfWeek(Now());'
+"today = DayOfWeek(Now());"
-'Now()' gets the current date and time of the computer running the ColdFusion server. 'DayOfWeek' returns an integer in the range 1 (Sunday) to 7 (Saturday) for the day of the week. We still don't have the day of week as string. Try this:
+"Now()" gets the current date and time of the computer running the ColdFusion server. "DayOfWeek" returns an integer in the range 1 (Sunday) to 7 (Saturday) for the day of the week. We still don't have the day of week as string. Try this:
#### Tag
@@ -418,9 +418,9 @@ writeOutput(message);
</cfscript>
```
-Great, no errors and our output looks correct. 'DayOfWeekAsString' did the trick. There is another string combination called *string interpolation*.
+Great, no errors and our output looks correct. "DayOfWeekAsString" did the trick. There is another string combination called *string interpolation*.
-**String interpolation** is the process of sticking data into the middle of strings. We use the symbols '#' around the 'variable' where in a string the value should be inserted. Inside those hashes we can put any variable and output it in that spot. Our previous example 'message' could be rewritten like this:
+**String interpolation** is the process of sticking data into the middle of strings. We use the symbols ```#``` around the "variable" where in a string the value should be inserted. Inside those hashes we can put any variable and output it in that spot. Our previous example "message" could be rewritten like this:
#### Tag
@@ -436,11 +436,11 @@ message = "Happy #today#!";
If you compare the output you'll see the second example gives the exact same results. The code itself is a little more compact and, personally, I find it much easier to read.
-Basically *interpolating* means evaluate the code inside this '#' wrapper and put it into the string.
+Basically *interpolating* means evaluate the code inside this ```#``` wrapper and put it into the string.
## 5. Numbers
-There are two basic kinds of numbers in CFML: integers (whole numbers) and real (numbers with a decimal point). For our workshop, we'll only be dealing with integers. You can use normal math operations with integers including '+', '-', '/', and '*'. The '++' operator can be used to increment a number. It is also the only one we will use to control a loop. We will talk more about Conditional Looping in section 9. Try out this example for the '++' operator:
+There are two basic kinds of numbers in CFML: integers (whole numbers) and real (numbers with a decimal point). For our workshop, we'll only be dealing with integers. You can use normal math operations with integers including "+", "-", "/", and "*". The "++" operator can be used to increment a number. It is also the only one we will use to control a loop. We will talk more about Conditional Looping in section 9. Try out this example for the "++" operator:
#### Tag
@@ -465,9 +465,9 @@ WriteOutput("I am here<br>");
</cfscript>
```
-In this next example we're using the 'cfloop' instruction with a multiple instructions inside the condition. The CFML script syntax looks for the starting '{' and the ending '}'. Each instruction between the beginning '{' and ending '}' will be executed if the condition is true.
+In this next example we're using the "cfloop" instruction with a multiple instructions inside the condition. The CFML script syntax looks for the starting "{" and the ending "}". Each instruction between the beginning "{" and ending "}" will be executed if the condition is true.
-In the tag example there's no need to manage the index inside the loop if you're simply stepping through one item at a time. You can use the 'from' and 'to' arguments, and ColdFusion will simply loop from the first value to the second, and automatically increment the variable in the 'index' argument.
+In the tag example there's no need to manage the index inside the loop if you're simply stepping through one item at a time. You can use the "from" and "to" arguments, and ColdFusion will simply loop from the first value to the second, and automatically increment the variable in the "index" argument.
Try this example with multiple instructions:
@@ -496,7 +496,7 @@ while (loop < 5) {
</cfscript>
```
-It's also possible to go through a loop and step over more than one value at a time. The following examples will step through the loop and increase the 'loop' index by two for each time through the loop.
+It's also possible to go through a loop and step over more than one value at a time. The following examples will step through the loop and increase the "loop" index by two for each time through the loop.
#### Tag
@@ -525,7 +525,7 @@ while (loop < 5) {
## 6. Queries
-A query is a request to a database. The query can ask for information from the database, write new data to the database, update existing information in the database, or delete records from the database. Each time you query a database with CFML, you get the data (the recordset) and the query variables; together they make up the query object. 'cfquery' passes SQL statements to the 'datasource'. The 'datasource' is set in the ColdFusion administrator.
+A query is a request to a database. The query can ask for information from the database, write new data to the database, update existing information in the database, or delete records from the database. Each time you query a database with CFML, you get the data (the recordset) and the query variables; together they make up the query object. "cfquery" passes SQL statements to the "datasource". The "datasource" is set in the ColdFusion administrator.
#### Tag
@@ -555,15 +555,15 @@ GetBreakfastItems = queryService.execute().getResult();
</cfscript>
```
-In order to display the data from our query, we need to loop through the rows, and display each row. This is usually done in a '<cfoutput>' tag like so:
+In order to display the data from our query, we need to loop through the rows, and display each row. This is usually done in a ```<cfoutput>``` tag like so:
```cfm
<cfoutput query="GetBreakfastItems">
There are #GetBreakfastItems.Quantity# #GetBreakfastItems.Item# in the pantry<br />
</cfoutput>
```
-While it's not strictly necessary to prepend the recordset name before the column name inside the '<cfoutput>', it's strongly recommended that you do in order to prevent referencing the wrong variable scope.
+While it's not strictly necessary to prepend the recordset name before the column name inside the ```<cfoutput>```, it's strongly recommended that you do in order to prevent referencing the wrong variable scope.
You can also loop through a query using standard loop constructs, though they differ when using tags and script.
@@ -585,15 +585,15 @@ for (x = 1; x <= GetBreakfastItems; x=x+1) {
</cfscript>
```
-When looping through a query with '<cfloop>', you need to make sure you have a '<cfoutput>' tag around your content (or around the loop) to ensure the ColdFusion instructions are recognized.
+When looping through a query with ```<cfloop>```, you need to make sure you have a ```<cfoutput>"``` tag around your content (or around the loop) to ensure the ColdFusion instructions are recognized.
-When looping through a query in 'cfscript', you'll need to reference the query just like you would a multidimensional array, using the counter set up in in your for statement to pick up the correct row from the recordset. So the syntax becomes 'recordsetName.ColumnName[rowNumber]'.
+When looping through a query in "cfscript", you'll need to reference the query just like you would a multidimensional array, using the counter set up in in your for statement to pick up the correct row from the recordset. So the syntax becomes "recordsetName.ColumnName[rowNumber]".
## 7. Arrays
Often we need to organize a group and put them into a *collection*. There are two main types of collections: **arrays** and **structures**.
-An **array** is a number-indexed list. Picture a city block of houses. Together they form an array and their addresses are the **indices**. Each house on the block will have a unique address. Some addresses might be empty, but the addresses are all in a specific order. The **index** is the address of a specific element inside the array. In CFML the index always begins with '1'. An array is defined in CFML as an opening '[' then zero or more elements, and a closing ']'. Try out this code:
+An **array** is a number-indexed list. Picture a city block of houses. Together they form an array and their addresses are the **indices**. Each house on the block will have a unique address. Some addresses might be empty, but the addresses are all in a specific order. The **index** is the address of a specific element inside the array. In CFML the index always begins with "1". An array is defined in CFML as an opening "[" then zero or more elements, and a closing "]". Try out this code:
#### Tag
@@ -645,13 +645,13 @@ writeOutput("<br>");
</cfscript>
```
-In order to get add an element in the array you use the syntax 'ArrayAppend(array,"value")' or 'arrayname[index] = "value**. The first example of adding an array element is **with an instruction**. The second is updating an array element is **by assignment**. So looking at the final 'favorite_colors' array:
+In order to get add an element in the array you use the syntax "ArrayAppend(array,"value")" or "arrayname[index] = "value**. The first example of adding an array element is **with an instruction**. The second is updating an array element is **by assignment**. So looking at the final "favorite_colors" array:
* What's the index of **brown** ?
-* What did the 'ArraySort' instuction do to the collection?
-* What does 'ArrayLen' instruction return?
+* What did the "ArraySort" instuction do to the collection?
+* What does "ArrayLen" instruction return?
-There are lots of cool things to do with an array. You can rearrange the order of the elements using the 'ArraySort' instruction like we did in the last example. You can iterate through each element using the 'cfloop' instruction. You can find the address of a specific element by using the 'arrayName[index]' instruction. You can ask an array if an element is present with the 'ArrayIsDefined' instruction. Try out this example that brings a bunch of things together:
+There are lots of cool things to do with an array. You can rearrange the order of the elements using the "ArraySort" instruction like we did in the last example. You can iterate through each element using the "cfloop" instruction. You can find the address of a specific element by using the "arrayName[index]" instruction. You can ask an array if an element is present with the "ArrayIsDefined" instruction. Try out this example that brings a bunch of things together:
#### Tag
@@ -688,7 +688,7 @@ We use arrays whenever we need a list where the elements are in a specific order
## 8. Structures
-A structure is a *collection of data* where each element of data is addressed by a name. As an analogy, think about a classroom of children. Under ideal circumstances, each student has a name and can be found by using that name. We might look in a science classroom for a child named Joey and that would result in finding an actual student. We could write this like 'science["Joey"]' which could be read as "look in the collection named 'science' and find the thing named 'Joey**.
+A structure is a *collection of data* where each element of data is addressed by a name. As an analogy, think about a classroom of children. Under ideal circumstances, each student has a name and can be found by using that name. We might look in a science classroom for a child named Joey and that would result in finding an actual student. We could write this like "science["Joey"]" which could be read as "look in the collection named "science" and find the thing named "Joey**.
A structure is an unordered collection, its just a bunch of data collected together where each one has a unique name/key. Structures have a slightly more complicated syntax:
@@ -702,7 +702,7 @@ A structure is an unordered collection, its just a bunch of data collected toget
<cfdump var="#ages#" />
<cfoutput>
-Joey is #ages['joey']# years old.
+Joey is #ages["joey"]# years old.
</cfoutput>
```
@@ -715,11 +715,11 @@ ages.joey = 12;
ages["jill"] = 14;
writeDump (var=ages);
-writeOutput ("Joey is #ages['joey']# years old.");
+writeOutput ("Joey is #ages["joey"]# years old.");
</cfscript>
```
-Here we create a structure named 'ages'. Structures are made up what are called key-value pairs.The **key** is used as the address and the **value** is the object at that address. In the 'ages' structure we have keys including **joey** and **jill** and values including '12' and '14'. When creating a structure using '{}' the key and value are linked by the '=' symbol. So to create a structure, the structures start with a curly bracket '{', have zero or more entries made up of a *key*, '=', and a *value* separated by commas, then end with a closing curly bracket '}'.
+Here we create a structure named "ages". Structures are made up what are called key-value pairs.The **key** is used as the address and the **value** is the object at that address. In the "ages" structure we have keys including **joey** and **jill** and values including "12" and "14". When creating a structure using "{}" the key and value are linked by the "=" symbol. So to create a structure, the structures start with a curly bracket "{", have zero or more entries made up of a *key*, "=", and a *value* separated by commas, then end with a closing curly bracket "}".
#### Tag
@@ -739,7 +739,7 @@ writeDump (var=ages);
</cfscript>
```
-In the second chunk of the example, we add a new key and value to the structure. Since the **jimmy** key wasn't in the original structure, it's added with the value of '14'. If the key **jimmy** already existed then the value would be replaced by '14'. Every key in a structure must be unique! In the second line we reference the key **joey** which already exists, so the value gets replaced with the '9'. Then, just to show you the state of the structure, we dump out the list of keys and the list of values.
+In the second chunk of the example, we add a new key and value to the structure. Since the **jimmy** key wasn't in the original structure, it's added with the value of "14". If the key **jimmy** already existed then the value would be replaced by "14". Every key in a structure must be unique! In the second line we reference the key **joey** which already exists, so the value gets replaced with the "9". Then, just to show you the state of the structure, we dump out the list of keys and the list of values.
#### Tag
@@ -763,19 +763,19 @@ for (i = 1; i LTE ArrayLen (students); i = i+1) {
}
```
-The last chunk of the example used StructSort to get the sorted array 'students' from 'ages'. Then, it iterated through the 'students' array using a loop and gave each element of the array the name 'student'. It then printed out one line with that student name and the students age from 'ages'.
+The last chunk of the example used StructSort to get the sorted array "students" from "ages". Then, it iterated through the "students" array using a loop and gave each element of the array the name "student". It then printed out one line with that student name and the students age from "ages".
While that last part probably seemed complicated, it's just to illustrate that structures are unordered.
## 9. Conditionals
-Conditional statements evaluate to 'true' or 'false' only. The most common conditional operators are '==' (equal), '!=' (not equal), '>' (greater than), '>=' (greater than or equal to), '<' (less than), and '<=' (less than or equal to). You can also define the operators as abbreviations: 'EQ', 'NEQ', 'GT', 'GTE', 'LT', and 'LTE'.
+Conditional statements evaluate to "true" or "false" only. The most common conditional operators are ```==``` (equal), ```!=``` (not equal), ```>``` (greater than), ```>=``` (greater than or equal to), ```<``` (less than), and ```<=``` (less than or equal to). You can also define the operators as abbreviations: ```EQ```, ```NEQ```, ```GT```, ```GTE```, ```LT```, and ```LTE```.
-Some instructions return a 'true' or 'false', so they're used in conditional statements. For example, 'IsArray' which is 'true' only when the variable is an 'array'. Structures have an instruction named 'StructKeyExists' which returns 'true' if a key is present in a structure.
+Some instructions return a "true" or "false", so they're used in conditional statements. For example, "IsArray" which is "true" only when the variable is an "array". Structures have an instruction named ```StructKeyExists``` which returns "true" if a key is present in a structure.
### 9. 1. If, Else If, & Else
-Why do we have conditional statements? Most often its to control conditional instructions, especially 'if' / 'else if' / 'else' structures. Lets write an example by adding a method to our 'PersonalChef' class:
+Why do we have conditional statements? Most often its to control conditional instructions, especially "if" / "else if" / "else" structures. Lets write an example by adding a method to our **PersonalChef** class:
#### Tag
@@ -824,24 +824,24 @@ Try this example using *5*, *7*, *8* and *9* for the values of *minutes*.
* When the *minutes* is 8, it goes like this: Is it *true* that 8 is less than 7? No. Next, is it *true* that 8 is equal to 7? No. Next, is it *true* that 8 is equal to 8? Yes, it is, so print out the line *It's boiling!*.
-Lastly, when total is 9, it goes:" Is it 'true' that 9 is less than 7?
+Lastly, when total is 9, it goes:" Is it "true" that 9 is less than 7?
-No. Next, is it 'true' that 9 is equal to 7? No. Next, is it 'true' that 9 is equal to 8? No. Since none of those are true, execute the 'else' and print the line 'Hot! Hot! Hot!'.
+No. Next, is it "true" that 9 is equal to 7? No. Next, is it "true" that 9 is equal to 8? No. Since none of those are true, execute the "else" and print the line "Hot! Hot! Hot!".
-An 'if' block has:
+An "if" block has:
-- One 'if' statement whose instructions are executed only if the
+* One "if" statement whose instructions are executed only if the
statement is true
-- Zero or more 'else if' statements whose instructions are executed
+* Zero or more "else if" statements whose instructions are executed
only if the statement is true
-- Zero or one 'else' statement whose instructions are executed if no
- 'if' nor 'else if' statements were true
+* Zero or one "else" statement whose instructions are executed if no
+ "if" nor "else if" statements were true
-Only *one* section of the 'if' / 'else if' / 'else' structure can have its instructions run. If the 'if' is 'true', for instance, CFML will never look at the 'else if'. Once one block executes, thats it.
+Only *one* section of the "if" / "else if" / "else" structure can have its instructions run. If the "if" is "true", for instance, CFML will never look at the "else if". Once one block executes, thats it.
### 9. 2. Looping
-Another time we use conditional statements is when we want to repeat a set of instructions. Try out this simple example by adding it to your 'PersonalChef.cfc' :
+Another time we use conditional statements is when we want to repeat a set of instructions. Try out this simple example by adding it to your _PersonalChef.cfc_:
#### Tag
@@ -851,7 +851,7 @@ Another time we use conditional statements is when we want to repeat a set of in
<cfset this.timer = "" />
<cfloop condition="#arguments.counter# GT 0">
<cfset this.timer &= "The counter is #arguments.counter#.<br>" />
- <cfset arguments.counter-- />
+ <cfset arguments.counter-* />
</cfloop>
<cfreturn this />
</cffunction>
@@ -864,47 +864,47 @@ public component function countdown (numeric counter){
this.timer = "";
while (counter GT 0) {
this.timer &= "The counter is #arguments.counter#.<br>";
- arguments.counter;
+ arguments.counter-;
}
return this;
}
```
-See how that works? The 'counter' starts out as whatever parameter we
-pass in. The 'while' instruction evaluates the conditional statement
-'arguments.counter GT 0' and finds that yes, the counter is greater than
+See how that works? The "counter" starts out as whatever parameter we
+pass in. The "while" instruction evaluates the conditional statement
+"arguments.counter GT 0" and finds that yes, the counter is greater than
zero. Since the condition is true, execute the instructions inside the
loop. First print out **The counter is #Arguments.counter#** then take
-the value of 'Arguments.counter', subtract one from it, and store it
-back into 'Arguments.counter'. Then the loop goes back to the
-'condition'/'while' statement. Is it still true? If so, print the line
+the value of "Arguments.counter", subtract one from it, and store it
+back into "Arguments.counter". Then the loop goes back to the
+"condition" / "while" statement. Is it still true? If so, print the line
and subtract one again. Keep repeating until the condition is false.
You can also combine conditional statements using logical operators. The
-most common are known as 'logical and' and 'logical or'. In CFML you can
-write a 'logical and' with either the word 'and' or with double
-ampersands like this: '&&'. You can write a 'logical or' with the word
-'or' or with double pipes like this: '||'. For each operation, the
-symbolic representation ( '&&' and '||' ) is more common.
+most common are known as "logical and" and "logical or". In CFML you can
+write a "logical and" with either the word "and" or with double
+ampersands like this: "&&". You can write a "logical or" with the word
+"or" or with double pipes like this: "||". For each operation, the
+symbolic representation ( "&&" and "||" ) is more common.
The #1 mistake people encounter when writing conditional statements is
-the difference between '=' and '=='.
+the difference between "=" and "==".
-- '=' is an *assignment*. It means "take what's on the right side and
+* "=" is an *assignment*. It means "take what's on the right side and
stick it into whatever is on the left side" (or its *telling* not
*asking*.)
-- '==' is a *question*. It means "is the thing on the right equal to
+* "==" is a *question*. It means "is the thing on the right equal to
the thing on the left" (or its *asking* not *telling*.)
## 10. Nothingness & Null
What is *nothingness*? Is there nothingness only in outer space? Really, when we think of *nothing* isn't it just the absence of something? Ok, that's too much philosophy
-ColdFusion did not have a way of referring to nothingness until version 9. ColdFusion can recieve a 'NULL' value from an external source and maintain the 'NULL' value until you try to use it. ColdFusion will convert the 'NULL' into an empty string (in the case of queries) or potentially destroy the variable altogether. However now with greater support for 'NULL' values, ColdFusion allows you to pass in and return a 'NULL' value from a method. 'IsNull()' instruction will test for 'NULL' values and return 'true' or 'false'.
+ColdFusion did not have a way of referring to nothingness until version 9. ColdFusion can recieve a "NULL" value from an external source and maintain the "NULL" value until you try to use it. ColdFusion will convert the "NULL" into an empty string (in the case of queries) or potentially destroy the variable altogether. However now with greater support for "NULL" values, ColdFusion allows you to pass in and return a "NULL" value from a method. "IsNull()" instruction will test for "NULL" values and return "true" or "false".
-If you have three eggs, eat three eggs, then you might think you have *nothing* , but in terms of eggs you have '0'. Zero is something, its a number, and its *not nothing*.
+If you have three eggs, eat three eggs, then you might think you have *nothing* , but in terms of eggs you have "0". Zero is something, its a number, and its *not nothing*.
-A large percentage of the errors you encounter while writing CFML code will involve a variable not existing. You thought something was there, you tried to do something to it, and you can't do something to nothing so CFML creates an error. Lets rewrite our 'makeeggs' method to illustrate 'NULL' :
+A large percentage of the errors you encounter while writing CFML code will involve a variable not existing. You thought something was there, you tried to do something to it, and you can't do something to nothing so CFML creates an error. Lets rewrite our "makeeggs" method to illustrate "NULL" :
#### Tag
@@ -942,6 +942,6 @@ eggs?";
}
```
-Reload the file, call 'frank.makeeggs(3)' then try 'frank.makeeggs()'.
+Reload the file, call "frank.makeeggs(3)" then try "frank.makeeggs()".
**TODO: Conclusion**
View
8 readme.markdown
@@ -4,7 +4,7 @@ CFML in 100 minutes was modified from [Ruby in 100 Minutes](http://jumpstartlab.
## Where is CFML in 100 minutes?
-CFML in 100 minutes is a simple textile file for easy editing and contributions called 'cfml100mins.textile'. Textile is a lightweight markup language that converts its marked-up text input to valid, well-formed XHTML. You can click on the [cfml100mins.textile](https://github.com/mhenke/CFML-in-100-minutes/blob/master/cfml100mins.textile) link to view the converted page.
+CFML in 100 minutes is a simple textile file for easy editing and contributions called "cfml100mins.textile". Textile is a lightweight markup language that converts its marked-up text input to valid, well-formed XHTML. You can click on the [cfml100mins.textile](https://github.com/mhenke/CFML-in-100-minutes/blob/master/cfml100mins.textile) link to view the converted page.
## License
@@ -14,11 +14,11 @@ These works were originally created by Jeff Casimir ([jeff@jumpstartlab.com](mai
Please add yourself if you help:
-Mike Henke ([henke.mike@gmail.com](mailto:henke.mike@gmail.com)) - [https://github.com/mhenke/](https://github.com/mhenke/)
+Mike Henke ([henke.mike@gmail.com](mailto:henke.mike@gmail.com)) * [https://github.com/mhenke/](https://github.com/mhenke/)
-russplaysguitar - [https://github.com/russplaysguitar/](https://github.com/russplaysguitar/)
+russplaysguitar * [https://github.com/russplaysguitar/](https://github.com/russplaysguitar/)
-Daniel Short (@danshort on twitter) - [http://www.dansshorts.com](http://www.dansshorts.com)
+Daniel Short (@danshort on twitter) * [http://www.dansshorts.com](http://www.dansshorts.com)
## Git Workflow for Contributors

0 comments on commit 040d17c

Please sign in to comment.