Skip to content

Commit

Permalink
added 1 space around "=" sign so it's the same in each example.
Browse files Browse the repository at this point in the history
  • Loading branch information
Kristofp committed Oct 5, 2011
1 parent f9677e2 commit ebc22f0
Showing 1 changed file with 46 additions and 46 deletions.
92 changes: 46 additions & 46 deletions cfml100mins.markdown
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ We might have a file named _myprogram.cfm_ and _Sample.cfc_ like this:


```cfm ```cfm
<cfcomponent> <cfcomponent>
<cffunction name="hello"> <cffunction name = "hello">
<cfreturn "Hello, World!" /> <cfreturn "Hello, World!" />
</cffunction> </cffunction>
</cfcomponent> </cfcomponent>
Expand Down Expand Up @@ -223,8 +223,8 @@ Inside the CFC we usually define one or more methods using the ```cffunction```
#### Tag Syntax #### Tag Syntax


```cfm ```cfm
<cfcomponent name="PersonalChef"> <cfcomponent name = "PersonalChef">
<cffunction name="makeToast"> <cffunction name = "makeToast">
<cfset makeToast = "Making your toast!" /> <cfset makeToast = "Making your toast!" />
</cffunction> </cffunction>
</cfcomponent> </cfcomponent>
Expand All @@ -233,7 +233,7 @@ Inside the CFC we usually define one or more methods using the ```cffunction```
#### Script Syntax #### Script Syntax


```cfm ```cfm
component name="PersonalChef" { component name = "PersonalChef" {
public string function makeToast(){ public string function makeToast(){
makeToast = "Making your toast!"; makeToast = "Making your toast!";
} }
Expand Down Expand Up @@ -271,9 +271,9 @@ Sometimes methods take one or more *parameters* telling them **how** to do what
#### Tag Syntax #### Tag Syntax


```cfm ```cfm
<cfcomponent name="PersonalChef"> <cfcomponent name = "PersonalChef">
<cffunction name="makeToast" returnType="string"> <cffunction name = "makeToast" returnType = "string">
<cfargument name="color" required="yes"> <cfargument name = "color" required = "yes">
<cfset makeToast = "Making your toast #arguments.color#!" /> <cfset makeToast = "Making your toast #arguments.color#!" />
</cffunction> </cffunction>
</cfcomponent> </cfcomponent>
Expand All @@ -282,7 +282,7 @@ Sometimes methods take one or more *parameters* telling them **how** to do what
#### Script Syntax #### Script Syntax


```cfm ```cfm
component name="PersonalChef" { component name = "PersonalChef" {
public string function makeToast(required String color){ public string function makeToast(required String color){
makeToast = "Making your toast #arguments.color#!"; makeToast = "Making your toast #arguments.color#!";
} }
Expand All @@ -302,9 +302,9 @@ For the purposes of our next section I’m going to return the chef instance its
#### Tag Syntax #### Tag Syntax


```cfm ```cfm
<cfcomponent name="PersonalChef"> <cfcomponent name = "PersonalChef">
<cffunction name="makeToast" returnType="component"> <cffunction name = "makeToast" returnType = "component">
<cfargument name="color" required="yes"> <cfargument name = "color" required="yes">
<cfset this.makeToast = "Making your toast #arguments.color#!" /> <cfset this.makeToast = "Making your toast #arguments.color#!" />
<cfreturn this /> <cfreturn this />
</cffunction> </cffunction>
Expand All @@ -314,7 +314,7 @@ For the purposes of our next section I’m going to return the chef instance its
#### Script Syntax #### Script Syntax


```cfm ```cfm
component name="PersonalChef" { component name = "PersonalChef" {
public component function makeToast(required String color){ public component function makeToast(required String color){
this.makeToast = "Making your toast #arguments.color#!"; this.makeToast = "Making your toast #arguments.color#!";
return this; return this;
Expand Down Expand Up @@ -508,7 +508,7 @@ Try this example with multiple instructions:
```cfm ```cfm
<cfset loop = 0 /> <cfset loop = 0 />
<cfoutput> <cfoutput>
<cfloop index="loop" from="0" to="4"> <cfloop index="loop" from = "0" to = "4">
#loop# Good Morning! #loop# Good Morning!
...is it lunch time yet?<br /> ...is it lunch time yet?<br />
</cfloop> </cfloop>
Expand Down Expand Up @@ -559,7 +559,7 @@ A query is a request to a database. It returns ```query object``` containing a *
#### Tag Syntax #### Tag Syntax


```cfm ```cfm
<cfquery name="GetBreakfastItems" datasource="pantry"> <cfquery name = "GetBreakfastItems" datasource="pantry">
SELECT QUANTITY, ITEM SELECT QUANTITY, ITEM
FROM CUPBOARD FROM CUPBOARD
ORDER BY ITEM ORDER BY ITEM
Expand Down Expand Up @@ -587,7 +587,7 @@ GetBreakfastItems = queryService.execute().getResult();
In order to display the data from our query object, 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 object, we need to loop through the rows, and display each row. This is usually done in a ```<cfoutput>``` tag like so:


```cfm ```cfm
<cfoutput query="GetBreakfastItems"> <cfoutput query = "GetBreakfastItems">
There are #GetBreakfastItems.Quantity# #GetBreakfastItems.Item# in the pantry<br /> There are #GetBreakfastItems.Quantity# #GetBreakfastItems.Item# in the pantry<br />
</cfoutput> </cfoutput>
``` ```
Expand All @@ -601,10 +601,10 @@ For a single value the cfqueryparam tag is used like so:


#### Tag Syntax #### Tag Syntax
```cfm ```cfm
<cfquery name="GetBreakfastItem" datasource="pantry"> <cfquery name = "GetBreakfastItem" datasource = "pantry">
SELECT QUANTITY, ITEM SELECT QUANTITY, ITEM
FROM CUPBOARD FROM CUPBOARD
WHERE ITEM_ID = <cfqueryparam cfsqltype="CF_SQL_INTEGER" value="#itemID#"> WHERE ITEM_ID = <cfqueryparam cfsqltype="CF_SQL_INTEGER" value = "#itemID#">
</cfquery> </cfquery>
``` ```


Expand All @@ -621,18 +621,18 @@ queryService.setSQL("
WHERE ITEM_ID = :itemID WHERE ITEM_ID = :itemID
"); ");
queryService.addParam(name="itemID",cfsqltype="CF_SQL_INTEGER",value=itemID); queryService.addParam(name = "itemID",cfsqltype="CF_SQL_INTEGER",value = itemID);
GetBreakfastItem = queryService.execute().getResult(); GetBreakfastItem = queryService.execute().getResult();
</cfscript> </cfscript>
``` ```
When passing in a list of information the cfqueryparam tag can also be used like so: When passing in a list of information the cfqueryparam tag can also be used like so:
#### Tag Syntax #### Tag Syntax
```cfm ```cfm
<cfquery name="GetBreakfastItems" datasource="pantry"> <cfquery name = "GetBreakfastItems" datasource="pantry">
SELECT QUANTITY, ITEM SELECT QUANTITY, ITEM
FROM CUPBOARD FROM CUPBOARD
WHERE ITEM_ID IN(<cfqueryparam list="true" cfsqltype="CF_SQL_VARCHAR" value="#itemID#">) WHERE ITEM_ID IN(<cfqueryparam list="true" cfsqltype = "CF_SQL_VARCHAR" value = "#itemID#">)
</cfquery> </cfquery>
``` ```
#### Script Using #### Script Using
Expand All @@ -648,7 +648,7 @@ queryService.setSQL("
WHERE ITEM_ID = :itemID WHERE ITEM_ID = :itemID
"); ");
queryService.addParam(name="itemID",cfsqltype="CF_SQL_VARCHAR",value=itemID,list=true); queryService.addParam(name = "itemID",cfsqltype = "CF_SQL_VARCHAR",value = itemID,list = true);
GetBreakfastItem = queryService.execute().getResult(); GetBreakfastItem = queryService.execute().getResult();
</cfscript> </cfscript>
Expand All @@ -664,7 +664,7 @@ When looping through a query with ```<cfloop>```, you need to make sure you have
#### Tag Syntax #### Tag Syntax


```cfm ```cfm
<cfloop query="GetBreakfastItems"> <cfloop query = "GetBreakfastItems">
<cfoutput>There are #GetBreakfastItems.Quantity# #GetBreakfastItems.Item# in the pantry<br /></cfoutput> <cfoutput>There are #GetBreakfastItems.Quantity# #GetBreakfastItems.Item# in the pantry<br /></cfoutput>
</cfloop> </cfloop>
``` ```
Expand All @@ -691,9 +691,9 @@ An **array** is a number-indexed list. Picture a city block of houses. Together


```cfm ```cfm
<cfset favorite_colors = ["red","blue","green","black","brown"] /> <cfset favorite_colors = ["red","blue","green","black","brown"] />
<cfdump var="#favorite_colors#" /><br /> <cfdump var = "#favorite_colors#" /><br />
<cfdump var="#favorite_colors[2]#" /><br /> <cfdump var = "#favorite_colors[2]#" /><br />
<cfdump var="#ArrayLen(favorite_colors)#" /><br /> <cfdump var = "#ArrayLen(favorite_colors)#" /><br />
``` ```


#### Script Syntax #### Script Syntax
Expand All @@ -705,7 +705,7 @@ writeDump(favorite_colors);
writeOutput("<br />"); writeOutput("<br />");
writeDump(favorite_colors[2]); writeDump(favorite_colors[2]);
writeOutput("<br />"); writeOutput("<br />");
writeDump(var=ArrayLen(favorite_colors)); writeDump(var = ArrayLen(favorite_colors));
</cfscript> </cfscript>
``` ```


Expand All @@ -715,11 +715,11 @@ Keep going with these, but try to understand what each instruction is doing befo


```cfm ```cfm
<cfset ArrayAppend(favorite_colors, "orange") /> <cfset ArrayAppend(favorite_colors, "orange") />
<cfset favorite_colors[3]="yellow" /> <cfset favorite_colors[3] = "yellow" />
<cfdump var="#favorite_colors#" /><br /> <cfdump var = "#favorite_colors#" /><br />
<cfset ArraySort(favorite_colors,"text") /> <cfset ArraySort(favorite_colors,"text") />
<cfset ArrayDeleteAt(favorite_colors, 2) /> <cfset ArrayDeleteAt(favorite_colors, 2) />
<cfdump var="#favorite_colors#" /><br /> <cfdump var = "#favorite_colors#" /><br />
``` ```


#### Script Syntax #### Script Syntax
Expand All @@ -732,7 +732,7 @@ writeDump(favorite_colors);
writeOutput("<br />"); writeOutput("<br />");
ArraySort(favorite_colors,"text"); ArraySort(favorite_colors,"text");
ArrayDeleteAt(favorite_colors, 2); ArrayDeleteAt(favorite_colors, 2);
writeDump(var=favorite_colors); writeDump(var = favorite_colors);
writeOutput("<br />"); writeOutput("<br />");
</cfscript> </cfscript>
``` ```
Expand All @@ -750,13 +750,13 @@ There are lots of cool things to do with an array. You can rearrange the order o
```cfm ```cfm
<cfoutput> <cfoutput>
<ul> <ul>
<cfloop array="#favorite_colors#" index="target" > <cfloop array = "#favorite_colors#" index = "target" >
<li> <li>
#target# is #len(target)# letters long. #target# is #len(target)# letters long.
</li> </li>
</cfloop> </cfloop>
</ul> </ul>
<cfdump var="#ArrayIsDefined(favorite_colors,4)#" /> <cfdump var = "#ArrayIsDefined(favorite_colors,4)#" />
</cfoutput> </cfoutput>
``` ```


Expand All @@ -772,7 +772,7 @@ while (index.hasNext ()){
long.</li>"); long.</li>");
} }
writeOutput ("</ul>"); writeOutput ("</ul>");
writeDump (var=ArrayIsDefined (favorite_colors,4)); writeDump (var = ArrayIsDefined (favorite_colors,4));
</cfscript> </cfscript>
``` ```


Expand All @@ -791,7 +791,7 @@ A structure is an unordered collection, it’s just a bunch of data collected to
<cfset ages.joey = 12 /> <cfset ages.joey = 12 />
<cfset ages["jill"] = 14 /> <cfset ages["jill"] = 14 />
<cfdump var="#ages#" /> <cfdump var = "#ages#" />
<cfoutput> <cfoutput>
Joey is #ages["joey"]# years old. Joey is #ages["joey"]# years old.
Expand All @@ -806,7 +806,7 @@ ages = {jack = 11, brian = 12, tracy = 11};
ages.joey = 12; ages.joey = 12;
ages["jill"] = 14; ages["jill"] = 14;
writeDump (var=ages); writeDump (var = ages);
writeOutput ("Joey is #ages["joey"]# years old."); writeOutput ("Joey is #ages["joey"]# years old.");
</cfscript> </cfscript>
``` ```
Expand All @@ -818,7 +818,7 @@ Here we create a structure named "ages". Structures are made up what are called
```cfm ```cfm
<cfset ages["jimmy"] = 14 /> <cfset ages["jimmy"] = 14 />
<cfset ages["joey"] = 9 /> <cfset ages["joey"] = 9 />
<cfdump var="#ages#" /> <cfdump var = "#ages#" />
``` ```


#### Script Syntax #### Script Syntax
Expand All @@ -827,7 +827,7 @@ Here we create a structure named "ages". Structures are made up what are called
<cfscript> <cfscript>
ages["jimmy"] = 14; ages["jimmy"] = 14;
ages["joey"] = 9; ages["joey"] = 9;
writeDump (var=ages); writeDump (var = ages);
</cfscript> </cfscript>
``` ```


Expand All @@ -838,7 +838,7 @@ In the second chunk of the example, we add a new key and value to the structure.
```cfm ```cfm
<cfset StructSort(ages)> <cfset StructSort(ages)>
<cfloop collection="#ages#" item="student"> <cfloop collection = "#ages#" item = "student">
<cfoutput>"#student# is #ages[student]# years old."<br /> <cfoutput>"#student# is #ages[student]# years old."<br />
</cfoutput> </cfoutput>
</cfloop> </cfloop>
Expand Down Expand Up @@ -872,8 +872,8 @@ Why do we have conditional statements? Most often its to control conditional ins
#### Tag Syntax #### Tag Syntax


```cfm ```cfm
<cffunction name="water_boiling" returnType="component"> <cffunction name = "water_boiling" returnType = "component">
<cfargument name="minutes" type="numeric" required="yes"> <cfargument name = "minutes" type = "numeric" required = "yes">
<cfif (arguments.minutes LT 7)> <cfif (arguments.minutes LT 7)>
<cfset this.status = "The water is not boiling yet." /> <cfset this.status = "The water is not boiling yet." />
Expand Down Expand Up @@ -943,10 +943,10 @@ Another time we use conditional statements is when we want to repeat a set of in
#### Tag Syntax #### Tag Syntax


```cfm ```cfm
<cffunction name="countdown" returnType="component"> <cffunction name = "countdown" returnType = "component">
<cfargument name="counter" type="numeric"> <cfargument name = "counter" type = "numeric">
<cfset this.timer = "" /> <cfset this.timer = "" />
<cfloop condition="#arguments.counter# GT 0"> <cfloop condition = "#arguments.counter# GT 0">
<cfset this.timer &= "The counter is #arguments.counter#.<br />" /> <cfset this.timer &= "The counter is #arguments.counter#.<br />" />
<cfset arguments.counter-- /> <cfset arguments.counter-- />
</cfloop> </cfloop>
Expand Down Expand Up @@ -1005,15 +1005,15 @@ A large percentage of the errors you encounter while writing CFML code will invo
#### Tag Syntax #### Tag Syntax


```cfm ```cfm
<cffunction name="makeEggs" returnType="component"> <cffunction name = "makeEggs" returnType = "component">
<cfargument name="quantity" type="numeric"> <cfargument name = "quantity" type="numeric">
<cfif (IsNull(arguments.quantity)) /> <cfif (IsNull(arguments.quantity)) />
<cfset local.makeEggs = "How am I supposed to make nothingness number of eggs?" /> <cfset local.makeEggs = "How am I supposed to make nothingness number of eggs?" />
<cfelse> <cfelse>
<cfset local.makeEggs = "Making your #arguments.quantity# eggs!" /> <cfset local.makeEggs = "Making your #arguments.quantity# eggs!" />
<cfset local.yourEggs = ArrayNew(1) /> <cfset local.yourEggs = ArrayNew(1) />
<cfloop condition="#ArrayLen(local.yourEggs)# LT #arguments.quantity#"> <cfloop condition = "#ArrayLen(local.yourEggs)# LT #arguments.quantity#">
<cfset ArrayAppend(local.yourEggs, "Making an Egg.") /> <cfset ArrayAppend(local.yourEggs, "Making an Egg.") />
</cfloop> </cfloop>
</cfif> </cfif>
Expand Down

0 comments on commit ebc22f0

Please sign in to comment.