Variables and Conditions Nicholas Tunney Senior Software Architect

Slides:



Advertisements
Similar presentations
Chapter 10: Designing Databases
Advertisements

CF and JSP/Servlets Developed originally by Robi Sen For the CF UnderGround II Seminar, Apr 2001 Edited and enhanced by Charlie Arehart (Robi had an emergency.
Intermediate Code Generation
Programming Paradigms and languages
Tutorial 6 Creating a Web Form
Expression Language Lec Umair Javed©2006 Generating Dynamic Contents Technologies available  Servlets  JSP  JavaBeans  Custom Tags  Expression.
 Copyright Wipro Technologies JSP Ver 1.0 Page 1 Talent Transformation Java Server Pages.
1 Chapter 4 Language Fundamentals. 2 Identifiers Program parts such as packages, classes, and class members have names, which are formally known as identifiers.
Variables and Conditionals Hal Helms halhelms.com.
Java Server Pages Russell Beale. What are Java Server Pages? Separates content from presentation Good to use when lots of HTML to be presented to user,
Introduction to Server-Side Web Development Introduction to Server-Side Web Development JSP Final Remarks 10 th March 2005 Bogdan L. Vrusias
CGI Programming: Part 1. What is CGI? CGI = Common Gateway Interface Provides a standardized way for web browsers to: –Call programs on a server. –Pass.
Sys Prog & Scripting - HW Univ1 Systems Programming & Scripting Lecture 15: PHP Introduction.
FALL 2005CSI 4118 – UNIVERSITY OF OTTAWA1 Part 4 Web technologies: HTTP, CGI, PHP,Java applets)
20-753: Fundamentals of Web Programming Copyright © 1999, Carnegie Mellon. All Rights Reserved. 1 Lecture 16: Java Applets & AWT Fundamentals of Web Programming.
Loops in CF Michael Smith President TeraTech, Inc ColdFusion, Database & VB custom development
Loops in CF: To loop or not to loop? Neil Ross
IT533 Lectures Session Management in ASP.NET. Session Tracking 2 Personalization Personalization makes it possible for e-businesses to communicate effectively.
® IBM Software Group © 2007 IBM Corporation JSP Expression Language
ColdFusion MX Rob Filardo and Lindsay Matteo A Brief History ColdFusion 1.0 was created in 1995 by Adam Berrey in order to help HTML programmers create.
ASP.NET Programming with C# and SQL Server First Edition Chapter 3 Using Functions, Methods, and Control Structures.
CMPS 211 JavaScript Topic 1 JavaScript Syntax. 2Outline Goals and Objectives Goals and Objectives Chapter Headlines Chapter Headlines Introduction Introduction.
Creating Dynamic Web Pages Using PHP and MySQL CS 320.
20-753: Fundamentals of Web Programming 1 Lecture 12: Javascript I Fundamentals of Web Programming Lecture 12: Introduction to Javascript.
Website Development with PHP and MySQL Saving Data.
Chapter 6 Server-side Programming: Java Servlets
1 © Netskills Quality Internet Training, University of Newcastle HTML Forms © Netskills, Quality Internet Training, University of Newcastle Netskills is.
Just a Little PHP Programming PHP on the Server. Common Programming Language Features Comments Data Types Variable Declarations Expressions Flow of Control.
CF Pest Control By Shlomy Gantz President, BlueBrick Inc. Presented by Sandra Clark
Java server pages. A JSP file basically contains HTML, but with embedded JSP tags with snippets of Java code inside them. A JSP file basically contains.
SE424 Languages with Context A Block Structured Language.
Loops in CF Sandra Clark Senior Software Developer Constella Group
Basic JSP Celsina Bignoli Problems with Servlets Servlets contain –request processing, –business logic –response generation all lumped.
Just a Little PHP Programming PHP on the Server. Common Programming Language Features Comments Data Types Variable Declarations Expressions Flow of Control.
Java Programming: Advanced Topics 1 Building Web Applications Chapter 13.
Dr. Abdullah Almutairi Spring PHP is a server scripting language, and a powerful tool for making dynamic and interactive Web pages. PHP is a widely-used,
Using Structures With CFCs By Selene Bainum. June 27 th - 30 th 2007www.cfunited.com Why Am I here? Familiar with structures Familiar with ColdFusion.
Windows Programming Lecture 03. Pointers and Arrays.
2440: 141 Web Site Administration Web Forms Instructor: Joseph Nattey.
PHP using MySQL Database for Web Development (part II)
Web Database Programming Using PHP
Information and Computer Sciences University of Hawaii, Manoa
CGS 3066: Web Programming and Design Spring 2017
Data Types In Text: Chapter 6.
Type Checking and Type Inference
Two-Dimensional Arrays
Type Checking, and Scopes
Web Database Programming Using PHP
DBW - PHP DBW2017.
PHP Introduction.
PHP.
Java Server Pages B.Ramamurthy.
Web DB Programming: PHP
Arrays Week 2.
Spreadsheets, Modelling & Databases
Introduction to Data Structure
JavaScript CS 4640 Programming Languages for Web Applications
Tutorial 10: Programming with javascript
Javascript Chapter 19 and 20 5/3/2019.
Pre-assessment Questions
PHP an introduction.
C++ Array 1.
PHP-II.
Web Programming and Design
SEEM 4540 Tutorial 4 Basic PHP based on w3Schools
[Based in part on SWE 432 and SWE 632 materials by Jeff Offutt, GMU]
JavaScript CS 4640 Programming Languages for Web Applications
Lecture 7: Types (Revised based on the Tucker’s slides) 10/4/2019
Presentation transcript:

Variables and Conditions Nicholas Tunney Senior Software Architect

What will we cover? Variable Basics Types of Variables ColdFusion Variable Scopes Conditional Logic

What is a variable? Container Name/value pair Dynamic (changing) Variables permit our programs to work with values that can't be known at design time or that may change from their original value

Data typing Different data types hold different types of values String: “Hello World” Int: 42 Structure: Object (Car) Name Nic Tunney Presenter True Age 28 getModel() Return string getMake() accelerate()

Strong data typing Must declare a variable’s type before it can be used String myName; Int myAge; Company myEmployer; Strongly typed languages Java C#

Weak data typing Language determines type of variable at runtime dynamically Weakly typed languages are NOT untyped languages Weakly typed languages Smalltalk ColdFusion

ColdFusion data types Simple: Strings (lists) Integers Real numbers Boolean values Date-time values

ColdFusion data types Binary Object Raw data such as images COM CORBA Java Web Services ColdFusion Components

ColdFusion data types Complex: Arrays Structures Queries

ColdFusion Arrays Array: Array Element A set of sequentially indexed elements having the same type of data. Each element of an array has a unique identifying index number. Changes made to one element of an array do not affect the other elements. Array Element Individual item stored within an array

One Dimensional Arrays Simple ordered stack of values Addressable Refer to each element using [x] myArray[1], myArray[2] myArray 1 Nic 2 Kelly 3 Simon

Two Dimensional Arrays Collection of ordered values Addressable Refer to each element as [x][y] myArray[1][1], myArray[2][2] myArray 1 2 Nic Tunney Simon Horwith

ColdFusion Structures A container (variable) that’s holds a group of data objects. Unlike arrays, each data object in a structure generally is of a different type Structures are unordered Addressable myStruct.speaker, myStruct[“topic”] myStruct speaker Nic Tunney topic Variables isActive true

ColdFusion Queries Series of 1 or more rows with column or field values for each row Addressable products.price – refers to current row products.price[2] – specifies row myQuery id price description 001 29.99 Widget 002 59.99 Foobar

Objects Objects are fundamentally different from all other data types in that they encapsulate both data and behavior Objects are real world representations Car getMake(): string addGas(gallons): void accelerate(): void

ColdFusion Scopes A variable typically has a lifespan and a scope lifespan: how long the system keeps a reference to a variable scope: location from which variable is visible In ColdFusion, a variable's scope and lifespan are bound together in a single attribute, scope, which is prefixed to the variable name

ColdFusion Scopes prefix visibility prefix required lifespan application everywhere in same app Yes life of application attributes within custom tag (for variables passed into custom tag) current request caller within custom tag (for variables on calling page) cgi everywhere No client everywhere in same application for an individual user varies by purge timeframe cookie everywhere in all apps on domain varies; set by cookie form request server everywhere by all apps on single server varies by server timeout setting session everywhere in same app for an individual user varies by session timeout setting url variables local to page/CFC and any included pages (default)

Conditional Expressions A conditional is an expression that can be evaluated to a boolean value Certain actions are taken depending on true versus false

<cfif> Evaluates an expression <cfif expression> Do Something </cfif>

<cfelseif> Allows us to add additional conditions if first condition is false <cfif expression> Do something <cfelseif different_expression> Do something else </cfif>

<cfelse> Handles the false condition of a <cfif> block “Catch All” condition <cfif expression> Do something <cfelse> Do something else </cfif>

<cfswitch><cfcase> Rule of threes Evaluates expression and passes control to the matching <cfcase> tag <cfswitch expression = "expression"> <cfcase value = "value" delimiters = "delimiters"> HTML and CFML tags </cfcase> … additional <cfcase></cfcase> tags … <cfdefaultcase> </cfdefaultcase> </cfswitch>

Operators ColdFusion Operator Equivalent to IS, EQUALS, EQ = LT < LTE, LE <= GT > GTE, GE >= IS NOT, NEQ <> CONTAINS N/A DOES NOT CONTAIN

Conclusion Variables are dynamic (changing) Variables give context and constraint to values Experiment with complex variables to help ease coding and maintenance time ColdFusion is a loosely typed language, but not untyped Conditionals allow us to execute commands based on the result of some run time boolean value

Conclusion This presentation laid the ground work for using variables and conditions in ColdFusion Next steps CF Tags Functions for complex data types AboutWeb Training Fast Track to ColdFusion Custom Class

Thanks! http://www.aboutweb.com http://www.nictunney.com