Variables and Conditions
From BriansWiki
Contents |
[edit] Presenter
[edit] Nick Tunney – AboutWeb.com
- Variable basics
- Types of variables
- Scopes
- Conditional Logic
[edit] Variable
- Container
- Name/value pair
- Dynamic
- Permit our program to work with information we don’t know at design Time
[edit] DataTyping
- String
- Integer
- Struct
- Object
[edit] Strongly Type Languages
Must declare a variable before you can use it and declare its type
[edit] Weak Data types
SmallTalk Coldfusion
[edit] Datatypes
Simple Strings and Integers Binary Objects
[edit] Complex
- Arrays
A set of sequentially indexed elements, useful when you need ordered same type data 2 dimensional arrays Addressable by element position and column
- Structures
Like an array but not ordered and not necessarily like data types Use associative array notation to refer to elements myStruct("index")
- Queries
Series of one or more rows with columns of field values for each row Addressable by array notation or by column names
- Objects
[edit] Cold Fusion Scopes
Scopes define a life span and where you can access a value
- Application
- Attributes
- Caller
- Cgi
- Client
- Cookie
- Form
- Request
- Server
- Session
- url
- variables
Always scope your variables to avoid checking all the scopes (variables is first so there is no real advantage but it makes for readability.
Variables – constrained to local cfc or cfm
Conditional Comparison:
- CFIF
- CFElseIF
- CFElse
If you have more than 3 conditions, use a switch
CFSwitch
Note you need to use actual values for comparisons (variables need ## to output values) Once it finds a match it will stop comparison
[edit] Operators
- Is, equals, eq: =
- LT
- LE, LTE: <
- GT >
- GE, GTE >=
[edit] Variables
Technically we have no constants in ColdFusion
