CF101: Intro to CFML as a language

Comments

There aren't any comments for this presentation.

Add Comment

Comments have been closed.

Transcript

no image

Slide Text

Slide Notes


Intro to CFML as a language


Intro to CFML as a language
Sam Farmer

no notes exist for this slide

About Me


About Me
CF Developer 10+ years
Work at Interfolio
Blog at samfarmer.com

no notes exist for this slide

Overview


Overview
Good to Know
Operators
Data Types
Query
Types of Files

no notes exist for this slide

Comments


Comments
Three dashes
Never sent to browser
<!--- My comment --->

no notes exist for this slide

Escaping


Escaping
Always double:
   ##
      <cfoutput>Here is a pound sign: ##</cfoutput>
   â€œâ€
      <cfset aString = “a quote “” in a string”>
   â€˜â€™

no notes exist for this slide

ColdFusion Starts at 1


ColdFusion Starts at 1
Loops, arrays, everything

no notes exist for this slide

Setting Variables amp Strings


Setting Variables & Strings
Use cfset
<cfset variables.myName = “Sam”>
<cfset variables.fullName = variables.myName & “Farmer”>
<cfset variables.a = 5>
<cfset variables.b = (variables.a * 5) + 10>
CF works out the type

no notes exist for this slide

To Pound or Not To Pound


To Pound or Not To Pound
Pound Signs Needed:
   in cfoutput
   passing variables to attributes
<cfoutput>#variables.myName#</cfoutput>
<cfswitch expression=“#variables.myName#”>
<cfset variables.myNameUpper =    Ucase(variables.myName)>
CF very forgiving

no notes exist for this slide

Operators


Operators
<cfif [not | !] a OPERATOR b>

no notes exist for this slide

cfif


cfif
<cfif variables.myName eq “Sam”>
   do something
<cfelseif variables.myName eq “Fred”>
   hi Fred
<cfelse>
   something else
</cfif>

no notes exist for this slide

Variables Scopes


Variables Scopes
ColdFusion puts variables into scopes
Better performance
Easier debugging

no notes exist for this slide

Variable Types amp Order of Evaluation


Variable Types & Order of Evaluation

no notes exist for this slide

Variable Types amp Order of Evaluation 2


Variable Types & Order of Evaluation 2

no notes exist for this slide

Always scoped variable types


Always scoped variable types

no notes exist for this slide

Complex Data Types


Complex Data Types
Structure
Array
List
Query

no notes exist for this slide

Structures


Structures
Everything is a structure!
Like map or associative array
<cfset variables.myStruct = {mon=“Monday”,tue=“Tuesday”}>
Key functions:
   StructDelete
   StructKeyExists
   StructSort

no notes exist for this slide

Arrays


Arrays
<cfset variables.myArray = [“Monday”,”Tuesday”]>
Key Functions:
   ArrayLen
   ArrayToList
   ListToArray
   ArraySort
   ArraySum

no notes exist for this slide

Old Structure and Array Syntax


Old Structure and Array Syntax
Pre ColdFusion 8:
<cfset variables.myStruct = StructNew()>
<cfset variables.myStruct.mon = “Monday”>
<cfset variables.myStruct.tue = “Tuesday”>
<cfset variables.myArray = ArrayNew(1)>
<cfset variables.myArray[1] = “Monday”>
<cfset variables.myArray[2] = “Tuesday”>

no notes exist for this slide

Lists


Lists
<cfset variables.myList = “Monday,Tuesday,Wednesday”>
Delimiter: Comma by default, other popular ones | ~
Key functions:
   ListAppend
   ListChangeDelims
   ListFindNoCase
   ListFirst
   ListLast

no notes exist for this slide

CF Administrator


CF Administrator
http://localhost[:8500]/cfide/administrator
Debugging
Datasources

no notes exist for this slide

Query


Query
Comes back from cfquery
Kind of array of structures
Query of Queries
Make Own queries
Returned from other tags as well like cfdirectory

no notes exist for this slide

Forms


Forms
Get vs Post
   Get = URL Scope
   Post = Form Scope
cfform

no notes exist for this slide

cfqueryparam


cfqueryparam
Always, always use with data from users

no notes exist for this slide

Types of Files


Types of Files
.cfm
Original
Include
Custom tag
ColdFusion Components (cfc)

no notes exist for this slide

CF Include


CF Include
cfinclude
   template=“”
Uses the variables scope of the original file

no notes exist for this slide

Custom Tag


Custom Tag
Very powerful feature
Especially for presentation
Passed values are attributes
Caller scope to pass back
<cf_
<cfmodule

no notes exist for this slide

CF Component CFC


CF Component (CFC)
Introduced in version 6
Collection of Functions
Use as Library or Objects

no notes exist for this slide

User Defined Functions


User Defined Functions
Write your own functions
cffunction
   name=“”
   access=“public | private | remote”
Var scope
   Always, always, always

no notes exist for this slide

QampA


Q&A

no notes exist for this slide