Coldfusion 8 Developer Tutorial John Farrar
download
https://ebookbell.com/product/coldfusion-8-developer-tutorial-
john-farrar-2087536
Explore and download more ebooks at ebookbell.com
Here are some recommended products that we believe you will be
interested in. You can click the link to download.
Coldfusion Mx Developers Handbook Raymond Camden Arman Danesh
https://ebookbell.com/product/coldfusion-mx-developers-handbook-
raymond-camden-arman-danesh-2005152
Coldfusion Mx Developers Cookbook Developers Library 1st Edition Peter
Freitag
https://ebookbell.com/product/coldfusion-mx-developers-cookbook-
developers-library-1st-edition-peter-freitag-2178966
Voicexml 20 Developers Guide Building Professional Voiceenabled
Applications With Jsp Asp Coldfusion 1st Dreamtech Software India
https://ebookbell.com/product/voicexml-20-developers-guide-building-
professional-voiceenabled-applications-with-jsp-asp-coldfusion-1st-
dreamtech-software-india-2206386
Voicexml 20 Developers Guide Building Professional Voiceenabled
Applications With Jsp Asp Coldfusion Dreamtech Software India
https://ebookbell.com/product/voicexml-20-developers-guide-building-
professional-voiceenabled-applications-with-jsp-asp-coldfusion-
dreamtech-software-india-4110456
Java For Coldfusion Developers 1st Eben Hewitt
https://ebookbell.com/product/java-for-coldfusion-developers-1st-eben-
hewitt-923390
Foundation Flex For Developers Datadriven Applications With Php Aspnet
Coldfusion And Lcds 1st Edition Sas Jacobs
https://ebookbell.com/product/foundation-flex-for-developers-
datadriven-applications-with-php-aspnet-coldfusion-and-lcds-1st-
edition-sas-jacobs-4164926
Macromedia Dreamweaver 8 With Asp Coldfusion And Php Training From The
Source Jeffrey Bardzell
https://ebookbell.com/product/macromedia-dreamweaver-8-with-asp-
coldfusion-and-php-training-from-the-source-jeffrey-bardzell-1339386
Coldfusion Presents New Thinking From Einstein To Artificial
Intelligence The Science And Technology That Transformed Our World
Ebook Dagogo Altraide
https://ebookbell.com/product/coldfusion-presents-new-thinking-from-
einstein-to-artificial-intelligence-the-science-and-technology-that-
transformed-our-world-ebook-dagogo-altraide-22683130
Coldfusion Mx Bible Adam Phillip Churvis Hal Helms Charles Arehart
https://ebookbell.com/product/coldfusion-mx-bible-adam-phillip-
churvis-hal-helms-charles-arehart-4566660
ColdFusion 8 Developer
Tutorial
An intense guide to creating professional ColdFusion
web applications: get up to speed in ColdFusion and
learn how to integrate with other web 2.0 technologies
John Farrar
BIRMINGHAM - MUMBAI
ColdFusion 8 Developer Tutorial
Copyright © 2008 Packt Publishing
All rights reserved. No part of this book may be reproduced, stored in a retrieval
system, or transmitted in any form or by any means, without the prior written
permission of the publisher, except in the case of brief quotations embedded in
critical articles or reviews.
Every effort has been made in the preparation of this book to ensure the accuracy of
the information presented. However, the information contained in this book is sold
without warranty, either express or implied. Neither the author, Packt Publishing,
nor its dealers or distributors will be held liable for any damages caused or alleged
to be caused directly or indirectly by this book.
Packt Publishing has endeavored to provide trademark information about all the
companies and products mentioned in this book by the appropriate use of capitals.
However, Packt Publishing cannot guarantee the accuracy of this information.
First published: June 2008
Production Reference: 1230608
Published by Packt Publishing Ltd.
32 Lincoln Road
Olton
Birmingham, B27 6PA, UK.
ISBN 978-1-847194-12-1
www.packtpub.com
Cover Image by Vinayak Chittar (vinayak.chittar@gmail.com)
Credits
Author
John Farrar
Reviewers
Rick Mason
Sean Corfield
Senior Acquisition Editor
Douglas Paterson
Development Editor
Ved Prakash Jha
Technical Editor
Shilpa Dube
Rasika Sathe
Copy Editor
Sumathi Sridhar
Editorial Team Leader
Mithil Kulkarni
Project Manager
Abhijeet Deobhakta
Project Coordinator
Lata Basantani
Indexer
Hemangini Bari
Proofreader
Chris Smith
Production Coordinator
Aparna Bhagat
Cover Work
Aparna Bhagat
About the Author
John Farrar started working with computer programming around 1977. He has
had the opportunity to work on projects used by Apple, Blue Cross, Brunswick
Recreation, Casio, GVSU, Johnson Controls, Sprint, and many others. This history
covers over 30 years of knowledge and experience in the industry.
He started doing web development over ten years ago. In the early days of the
Web, ColdFusion stood out to him not just as a way to make web pages into web
applications but as a maturing solid platform good for the developer, site owner, and
end users. He started at version 4.5 and has been enjoying every version upgrade
more and more.
John owns a company called SOSensible. His company does work for large
companies but has a special focus on also making sure technology is approachable
beyond the enterprise. It has developed a number of Open Source solutions
including COOP. COOP is a mix of "Custom Tags" and "CFCs" that provides
structure while keeping development simpler. It demonstrates his love for the things
that make ColdFusion/CFML a delightful language to build websites. COOP is a pet
project of his that can allow upgrades of AJAX libraries and add in features as the
libraries grow.
He has spoken at national and regional conferences, online meetings, and area
user group meetings. He is also an Adobe User Group manager. John knows that
community is a viable and productive tool to build developers and the companies
they serve. He has learned much from great resources in the community including
bloggers, books, conferences, and resources to great in number to mention here.
He blogs them at http://www.sosensible.com/index.cfm/blog/index/ and
encourages others to join in and build the community with him.
Contact: johnfarrar@sosensible.com
Alternative Email: sosensible@gmail.com.
Thanks to Douglas Paterson, and the many staff members of Packt
Publishing for helping me through my first published book. The
guides and interaction were a great experience that helped me in
numerous ways. There were a couple of community editors who
helped review technical content. These assistants were Sean Corfield
and Rick Mason and many of the suggestions made by them have
been added to this book and are on file towards any revisions in
the future. The efforts of the various people who work on Open
Source and share their work with the community at large should
be appreciated. Several were kind enough to work with me if there
were any questions in writing this book and it is truly appreciated.
Also thanks to the love of my life, Jeanine, who enthusiastically
motivated me to see the book through to completion.
About the Reviewers
Sean Corfield is the architect behind large-scale, high-availability websites for
companies such as Macromedia, Toshiba, Oracle, Toyota, and Thomas Cook. He is
a frequent speaker on software design within the ColdFusion community, at user
groups and conferences across the world. Sean has championed and contributed to
a number of ColdFusion frameworks and his passion for standards and software
engineering led him to work on the C++ Standards Committee for eight years.
He is currently Chief Systems Architect and Vice President of Engineering at
Broadchoice, Inc. based in the Bay Area, California.
Contact: sean@corfield.org
Rick Mason has been programming for over 20 years and has been a ColdFusion
developer since 1999. He started SeedChoices.com, an ASP sales force automation
solution for the farm seed industry seven years ago.
Mr. Mason is currently Senior Web Developer for SeeProgress.com. The Brighton,
MI based firm lets consumers view progress of repairs online. They were honored in
2007 as one of the top 50 companies in the state to watch by the Edward
Lowe foundation.
He also manages the Mid-Michigan ColdFusion Users Group, www.coldfusion.org,
and is an active member of the ColdFusion community.
Contact: rmason@acd.net
Alternative Email: Rick@SeedChoices.com
I would like to thank my nieces, Danielle and Sarah Stone, for their
continued inspiration.
Table of Contents
Preface 1
Chapter 1: Web Pages—Static to Dynamic 7
Turning HTML into a Dynamic Web Page 7
Understanding and Using Simple Variables 11
Understanding Structures 16
Let Us Get Interactive 18
Setting Page Defaults 23
Introduction to Lists and Loops 27
Understanding Arrays 29
Conditional Processing with If 32
Conditional Processing with Switch 35
Summary 36
Chapter 2: Basic CFCs and Database Interaction 37
Our First CFC 38
Our First Object 38
Product (object) 38
Using an Object Constructor 42
Connecting to a Database 45
Returning Data from the CFC 47
Making Our Data Query Flexible 50
The Basic Data Object Concept 53
Object Method Access Control 56
Summary 57
Chapter 3: Power CFCs and Web Forms 59
The Practice of Protecting Access 60
Web Forms Introduction 61
Managing Our Product Data 64
Getting Data to Our Edit Page 65
Table of Contents
[ ii ]
Saving Our Data 68
Improving Page Flow 71
Adding a New Record 72
Let Us Look Under the Hood 74
Summary 76
Chapter 4: Application, Session, and Request Scope 77
Life Span 77
Introducing the Application.cfc Object 79
Application Variables 82
The Start Methods 85
Application Start Method 85
Session Start Method 86
Request Start Method 87
The End Methods 87
Request End Method 88
Session End Method 88
Application End Method 88
On Error Method 89
Scope Visibility 89
Practical Application 92
Mappings per Application 93
Custom Tag Paths per Application 93
Summary 94
Chapter 5: Introduction to Custom Tags 95
Different Forms of Code Reuse 95
CFCs 96
Custom Tags 96
CFInclude 96
Our First Custom Tag 97
Custom Header/Footer Tags 98
Nested Tags 101
CFInclude from Custom Tags 106
Templates versus Skins 109
Managing Custom Tags 110
CFModule Approach 110
Tag Library Approach 111
Summary 111
Chapter 6: Better Interfaces for JavaScript Libraries 113
Thickbox Library HTML Style 114
ColdFusion-Powered Thickbox 116
Table of Contents
[ iii ]
Where Am I? (via Google Maps) 121
ColdFusion JavaScript 127
Multiple State Form Items 128
Inside the Fancy Form Tag 130
Summary 132
Chapter 7: Authentication and Permissions 133
How ColdFusion Recognizes Users 133
Custom Authentication (Additional Power) 138
Authentication Data Model 139
How to Use Advanced Authentication 142
Extra Notes 146
Summary 146
Chapter 8: CF AJAX User Interface 147
HTML-Based Websites 147
Server-Side Languages 148
Browser-Side Applications 148
Flash 148
JavaScript 148
ColdFusion AJAX 149
Layout 149
<cfdiv /> 149
<cflayout /> 151
<cfpod /> 157
<cfwindow /> 158
Menus and Tool Tips 163
<cfmenu /> 163
<cftooltip /> 166
Styling Notes 168
Tips 168
Summary 169
Chapter 9: CF AJAX Forms 171
Forms 171
<cfgrid /> 172
Grid Paging 173
Grid Updates and Deletes 176
Linked Grids 179
<cfinput /> 181
Binding Page Elements 181
Binding Immediately upon Load 182
The Date Requestor 184
Table of Contents
[ iv ]
The Autosuggest Box 185
<cfselect /> 187
<cftextarea /> 190
<cftree /> 192
The Directory Tree 194
Summary 197
Chapter 10: CF AJAX Programming 199
Binding 199
On Page Binding 200
CFC Binding 200
JavaScript Binding 202
URL Binding 203
Bind with Event 204
Extra Binding Notes 205
Multiple Radio Buttons or Check Boxes and Multiple Select 206
Spry Binding 206
CFAJAXProxy 206
CFAJAX Proxy Binding 207
CFC Proxy Class Objects 208
Client Debugging 213
Firebug 213
Built-In Debugging 215
Logging Features 216
Customization 217
Automatically Wired AJAX Links 218
Execute JavaScript after Loading Content 219
Other Cool Commands 220
Post for CFAJAX Calls 221
Summary 221
Chapter 11: Working with PDF 223
Generating PDF Pages 223
Our First PDF Page Conversion 223
Splitting into Sections 224
Adding Headers and Footers and Variables 225
Adding Page Breaks and Variables 226
Adding Bookmarks 227
Saving PDF Documents 228
Printing from the Server 228
Working with PDF Forms 230
Populating PDF Forms with Data 230
Table of Contents
[  ]
Reading Data from PDF Forms 233
Manipulating PDF Documents 234
Merging Documents 234
Deleting Pages 235
Encrypting PDF Documents 235
Generating Thumbnails 236
Adding Watermarks 237
Final Thoughts 238
Summary 239
Chapter 12: Building Search Abilities 241
Database Searching 241
Verity Search Solutions 241
Built-In Search Engine 242
Creating a Collection 242
Indexing a Collection 244
Searching a Collection 245
The Search Form 246
The Results Page 246
Search Techniques 248
PDF Linking to Searches 250
Suggestions 251
Integrating Third-Party Searching 252
Google Details 252
Custom Search Engines (Google) 253
On-The-Fly Search Engine 253
Simple Search 256
Search Types 257
Site Restricted 259
Local Search 260
Summary 261
Chapter 13: Working with Files, Email, and Images 263
Working with Files 263
Uploading Files 263
Local File Control 266
Write File 268
Read File 268
Rename File 269
Append File 270
Read File via Loop 270
Working with Email 270
Working with Images 274
Image Information 277
Summary 281
Table of Contents
[ vi ]
Chapter 14: Feeds, REST Services, and Web Services 283
Collaboration 283
Flickr 283
Feeds 283
RSS 284
CDF 288
JSON 289
SQL 292
Introduction to REST Services 292
SOAP Web Services 298
Summary 303
Chapter 15: Building Dynamic Reports 305
Traditional Web Page Reporting 305
Simple Report 305
Grouped Data 307
Drill-Down Reporting 309
Output Formats 311
PDF Output 312
Excel Output 313
CVS Output 315
XML Output 316
JSON Output 316
Using CFReport and Report Builder 317
Summary 325
Chapter 16: Dynamically Generated Web Presentations 327
Introduction to CFPresentation 327
Mixing in the Media 329
Caching the Contents 334
Dynamic Benefits 338
Scenario 1: Sales Force 338
Scenario 2: Client-Specific Presentations 339
Scenario 3: Live Audience Sensitive Content 339
Summary 340
Appendix A: Getting Your System Ready for Development 341
Tools 341
AJAX 344
Ant 345
Database Engines 345
Database Tools 347
Table of Contents
[ vii ]
Media Tools 347
Audio Software 348
Image Software 348
Video Software 349
Reporting 350
SVN 350
Unit Testing 350
Conclusions 351
Appendix B: Resources to Build Your Skills 353
Blogs 353
ColdFusion Conferences 354
Coding Frameworks 355
General ColdFusion Sites 357
Libraries and Tools 358
Aspect or IoC or DI 358
Content Handling/Generation 359
Database 359
JavaScript 361
Project Management 363
Script 363
Search 364
Site Integration APIs 364
Unit Testing or Debugging 370
XML Tools and Products 371
Other Notable Works 373
Index 375
Preface
Adobe ColdFusion is an application server, renowned for rapid development of
dynamic websites, with a straightforward language (CFML), powerful methods for
packaging and reusing your code, and AJAX support that will get developers deep
into powerful web applications quickly.
This book is the most intense guide to creating professional ColdFusion applications
available. Packed with example code, and written in a friendly, easy-to-read style,
this book is just want you need if you are serious about ColdFusion.
This book will give you clear, concise and, of course, practical guidance to take
you from the basics of ColdFusion 8 to the skills that will make you a ColdFusion
developer to be reckoned with.
ColdFusion expert John Farrar will teach you about the basics of ColdFusion
programming, application architecture, and object reuse, before showing you a range
of topics including AJAX library integration, RESTful Web Services, PDF creation
and manipulation, and dynamically generated presentation files that will make you
the toast of your ColdFusion developer town.
This book digs deep with the basics, with real-world examples of the how and whys,
to get more done faster with ColdFusion 8.
This book also covers the new features of ColdFusion 8 Update 1.
What This Book Covers
Chapter 1 describes how to enhance basic HTML pages with the power and simplicity
of ColdFusion. It also explains the difference between static HTML pages and
dynamic ColdFusion pages.
Preface
[  ]
Chapter 2 describes how to create object classes and instantiate object instances. It also
describes the object constructors. This chapter explains how to connect to a database
through the internal methods of our objects.
Chapter 3 helps us in understanding how to manage multiple products through
common forms for listing, editing, and adding data. This chapter explains integrating
and streamlining the workflow of web forms and CFC database processing.
In Chapter 4, we will learn how to use the web server memory to create engaging
and interactive web applications by using variable scopes. We will also learn how
to share some information, and how to protect the rest of the information in a
controlled manner.
In Chapter 5, we will learn about the basics of custom tags. We will also learn how to
integrate cfinclude for libraries of segments. This chapter also includes skinning
a website by using custom tags, the use of nested tags, and so on.
Chapter 6 includes wrapping of the ThickBox gallery functions into a custom tag for
simple functional reuse and wrapping of a Google map library into our code with a
custom tag for simplified interactive maps. This chapter helps us in understanding
how to create a multi-state form list wrapped in a custom tag.
In Chapter 7, we will see how to use the authentication that comes standard
with CF. This chapter explains how to control the site content based on current
user permissions.
In Chapter 8, we will see how AJAX is different from HTML and regular
server-oriented web pages. This chapter includes the comparison of HTML, server,
and browser technology sites. It also explains about the ColdFusion widgets.
In Chapter 9, we will see the benefit received from the combined power of tag-based
encapsulation with AJAX functionality.
Chapter 10 explains about binding, proxy connections, JSON features, Spry data
integration, and debugging.
In Chapter 11, we will have a look at the different ways in which we can reorganize
pages of PDF documents into a new PDF file from one or more separate PDF source
documents.
Chapter 12 explains how to create Verity search collections, how to initialize the
Verity indexes, how to interface with the indexes. This chapter also explains how to
interface with PDF content for more control when calling documents.
Preface
[  ]
Chapter 13 discusses files, emails, and images. This chapter helps in understanding
how some of the common ColdFusion features empower developers to shift the web
pages to web applications in many ways.
In Chapter 14, we will learn how to interact with other web servers and create
features on our site that will allow others to interact with us.
Chapter 15 gives a broad introduction to ColdFusion's way of generating
dynamic reports. This chapter also gives a brief introduction to the ColdFusion
Report Builder tool.
Chapter 16 shows the unique presentation capabilities built into ColdFusion. It gives
practical examples to help build custom presentations with dynamic content
on demand.
Appendix A covers some important details of setting up a development environment.
It also includes some important tips for better productivity.
Appendix B includes some links and resources that are aimed at giving us a good
starting base of information. It also explains a group of libaries that prove to be
very significant.
What You Need for This Book
For ColdFusion 8 Developer Tutorial, you will require the ColdFusion version 8.
Updater 1. You will need an SQL server for creating the databases or phpMyAdmin
site/SQL server will also do.
Who This Book Is For
This book is for web developers working with ColdFusion 8.
If your goal is to get a good grounding in the basics of the language as quickly as
possible and put a site together quickly, this book is ideal for you. If you want to learn
more about professional programming of ColdFusion, this book is definitely for you.
No prior knowledge of ColdFusion is expected, but basic knowledge of general web
and software development skills is assumed.
Preface
[  ]
Conventions
In this book, you will find a number of styles of text that distinguish between
different kinds of information. Here are some examples of these styles, and an
explanation of their meaning.
There are three styles for code. Code words in text are shown as follows: You
will also observe that there is an attribute called access=public in many of
the methods.
A block of code will be set as follows:
cfscript
objProduct = createObject(component,product_1).init();
objProduct.set_name(name=Egg Plant);
result = objProduct.get_name();
/cfscript
!--- Content ---
cfoutput
#result#
/cfoutput
When we wish to draw your attention to a particular part of a code block, the
relevant lines or items will be made bold:
tr
tdDescription:/td
td
textArea name=description id=idDescription/textArea
/td
/tr
New terms and important words are introduced in a bold-type font. Words that
you see on the screen, in menus or dialog boxes for example, appear in our text like
this: We could have your site link from About Us to a pop-up window rather than a
whole separate page.
Important notes appear in a box like this.
Tips and tricks appear like this.
Preface
[  ]
Reader Feedback
Feedback from our readers is always welcome. Let us know what you think about
this book, what you liked or may have disliked. Reader feedback is important for us
to develop titles that you really get the most out of.
To send us general feedback, simply drop an email to feedback@packtpub.com,
making sure to mention the book title in the subject of your message.
If there is a book that you need and would like to see us publish, please send
us a note in the SUGGEST A TITLE form on www.packtpub.com or email
suggest@packtpub.com.
If there is a topic that you have expertise in and you are interested in either writing
or contributing to a book, see our author guide on www.packtpub.com/authors.
Customer Support
Now that you are the proud owner of a Packt book, we have a number of things to
help you to get the most from your purchase.
Downloading the Example Code for the Book
Visit http://www.packtpub.com/files/code/4121_Code.zip to directly downlad
the example code.
The downloadable files contain instructions on how to use them.
Errata
Although we have taken every care to ensure the accuracy of our contents, mistakes
do happen. If you find a mistake in one of our books—maybe a mistake in text or
code—we would be grateful if you would report this to us. By doing this you can
save other readers from frustration, and help to improve subsequent versions of
this book. If you find any errata, report them by visiting http://www.packtpub.
com/support, selecting your book, clicking on the let us know link, and entering
the details of your errata. Once your errata are verified, your submission will be
accepted and the errata added to the list of existing errata. The existing errata can be
viewed by selecting your title from http://www.packtpub.com/support.
Questions
You can contact us at questions@packtpub.com if you are having a problem with
some aspect of the book, and we will do our best to address it.
Web Pages—Static to
Dynamic
In this chapter, you will learn how to enhance basic HTML pages with the power and
simplicity of ColdFusion. This book demonstrates how to apply different techniques
by building them into different real-world scenarios. In this chapter, we will apply
what we learn about a prototype of a typical FAQ (Frequently Asked Questions)
section of a website. We will cover the following skills in the process:
Moving from HTML to dynamic web pages
Simple and structured variables
URL and CGI variable structures
Setting default variables for pages
Debugging and exception-handling techniques
Working of lists and arrays in ColdFusion
Repetition processes done with looping commands
Conditional processing
Turning HTML into a Dynamic Web Page
Let us take a look at the differences between common HTML pages and the power of
a server-side language. For now, we will leave the pleasant side of web pages. This
is because we are going to focus our thinking on ColdFusion.
If you need help in setting up your system for development, see
Appendix A.
•
•
•
•
•
•
•
•
Web Pages—Static to Dynamic
[  ]
Copy the tutorial/chapter_1 directory to the cfb/chapter_1 directory inside
your server root. From your browser, enter� http://localhost/cfb/chapter_
1/1_1.htm in your address bar, and you will see a basic FAQ page. Open the view
source option from the browser, and compare that with the code you will find when
you open the file in an editor. You will find the same pages. Here, you will see that a
normal server returns common HTML pages.
When ColdFusion is added, we have an extra step to how the pages are managed by
the server. As a result, we are able to create pages that are made dynamic from the
server side of the equation. This concept is the same for all server-side languages.
Now, let us get into a very basic introduction to ColdFusion. We will take one step
at a time. Here is the code segment with common HTML. If you type the following
code in an HTML page and load it into the browser, it will look the same as it does in
the view source from the browser:
!-- Example: 1_1.htm --
!-- HTML Comment --
div
h3Question: What is a variable?/h3
pstrongAnswer:/strong/p
p Variables are named storage containers inside programming
languages. Just think of variables as any type of named container
holding any type of stored content. You simply name the container and
store the content. Later you retrieve the content by using the same
name./p
p12:53 PM/p
/div
Chapter 1
[  ]
Now, we will look at a more dynamic version of the page by listing the required
changes. You may be able to tell what is going on without any help, just by
depending on your programming background.
Copy the file 1_1.htm and save it as 1_2.cfm in the same directory. Go back to the
browser, and look for the web page, http://localhost/cfb/chapter_1/1_2.cfm.
This page looks the same, and the code is basically the same if you use the browser
page source view.
We are going to add the following two highlighted lines above the !-- HTML
Comment --:
!--- Processing ---
!--- Content ---
!-- HTML Comment --
You will notice that the two new lines have three dashes instead of two. This is
because they are ColdFusion comments. If you go back to the browser and refresh
the page, you will find something interesting when you view the source. The new
comment lines, which you had added, are not shown on the page source since they
are server-side ColdFusion comments. Remember to save the file before checking for
the results.
First we have to create variables in ColdFusion. Add a line between the processing
and content comments, and create the following two variables inside the CFSet tags.
These variables are containers to store content for later use. Currently, we will be
using them as text containers, and they will be known as string variables.
!--- Processing ---
cfset myQuestion = 
cfset myAnswer = 
!--- Content ---
Web Pages—Static to Dynamic
[ 10 ]
Cut the actual question out of the content section and paste it inside the quotes of the
string variable, myQuestion. Now, cut the answer text out of the content section and
paste it inside the quotes of the string variable,� myAnswer. (The question and answer
are the same as those specified in the previous example code.)
Now, we need to put the content, which we have moved to variables, back into the
page. ColdFusion was the first to standardize server-side code tags. These look very
much like HTML tags, but they add power and simplicity. We need to wrap our
entire content section with CFOutput. Add the� cfoutput opening tag right after
the� --- Content --- ����������������������
tag, and then put the /cfoutput closing tag as the last
line of the code page.
We have to place the variables in the content section of the code with some special
ColdFusion output markers. ColdFusion uses the pound symbols on both sides of
the dynamic content for markers. So put #myQuestion# in the place where you cut
out the content section for the myQuestion variable.
Also, place� #myAnswer# where you cut out the content section for the myAnswer
variable. Save the file, and then run the page. (Check the following sample code
for any issues to make sure that you typed things correctly. Then refresh the
page again.)
We can output more variables. You can also replace the time with the function in the
following code, at the end of the ColdFusion code sample. You can refresh the page
over and over, and see that the time is being dynamically generated on the server:
!--- Example: 1_2.cfm ---
!--- Proccessing ---
cfset myQuestion = What is a variable?
cfset myAnswer = Variables are named storage containers inside
programming languages. Just think of variables as any type of named
container holding any type of stored content. You simply name the
container and store the content. Later you retrieve the content by
using the same name.
!--- Content ---
cfoutput
div
h3Question: #myQuestion#/h3
pstrongAnswer:/strong/p
p#myAnswer# /p
p#timeFormat(now())#/p
/div
/cfoutput
Chapter 1
[ 11 ]
The now() function in ColdFusion returns the current date or time. The
timeFormat() function converts the output to display text with the time of its
contents. If we update the screen, the current time will be displayed on each refresh.
Your first dynamic web page is created. If you do not know much, there is no need to
worry. We will create web pages after this exercise. If you are new to this technology,
then work through the examples and complete the chapter. Take a break, and then
come back after going through the entire chapter, and repeat the exercises. You will
be surprised by what you have learned.
We will be removing the HTML standard wrappers from most of the
examples in the book. Browsers do not need the markers to present the
content. In your live site code, the markers should be included.
Understanding and Using
Simple Variables
In this section, we will have a look at a couple of variable types with the help of
which you will be getting an idea of how ColdFusion works with variables. We are
going to look at the different types of simple variables.
Web Pages—Static to Dynamic
[ 12 ]
There are four types of simple variables: string, numeric, Boolean, and date or time
variables. Although a variable can have any name, there are a few basic guidelines
for naming variables. They are as follows:
A variable name must begin with a letter, which can be followed by any
number of letters, numbers, and underscore characters.
A variable name cannot contain spaces.
Variable names are not case sensitive in ColdFusion. (myVariable is the
same in ColdFusion as Myvariable.)
We will be covering two number classes, in this lesson. First, we will take a look
at the integers. These are numbers with no decimal value. ColdFusion supports
integers between - 2,147,483,648 and 2,147,483,647. It will also work with numbers
outside this range, but the precision will not be exact.
In the first example given below, we will modify the code that we have been using
to keep one of the string variables and add a numeric variable called myAge. The
following two code examples are identical, so it is fine to do it either way. Proper
indentation is key to either tag or the script-based code. (Run the code examples.)
!--- Processing ---
cfset myQuestion = This is my question.
cfset myAge = 27
!--- Content ---
cfoutput
myQuestion is (#myQuestion#)br /
myAge is (#myAge#)br /
/cfoutput
!--- Processing ---
cfscript
myQuestion = This is my question.;
myAge = 27;
/cfscript
!--- Content ---
cfoutput
myQuestion is (#myQuestion#)br /
myAge is (#myAge#)br /
/cfoutput
•
•
•
Chapter 1
[ 13 ]
You will notice that strings are declared with quotation marks. These can be either
single or double quotation marks. Numbers do not use quotation marks. This would
be the same in a variable declaration. In the preceding examples, it is in the form
of an expression. Expressions are what we call code when we combine strings, or
do math or some Boolean comparisons. Here, we will look at our first expression
example by changing both the string and the numeric variables in our code.
ColdFusion 8 added the += operator to the platform. This is a widely used notation
to add the righthand value to the original value. Run the following example:
!--- Example: 1_3.cfm ---
!--- Processing ---
cfscript
myQuestion = This is my question.;
myAge = 27;
myQuestion = myQuestion   Is this a string?;
myAge += 1;
/cfscript
!--- Content ---
cfoutput
myQuestion is (#myQuestion#)br /
myAge is (#myAge#)br /
/cfoutput
There is no requirement to write things in CFScript like the ones you will
see in the book. Currently, JavaScript, AIR/Flash/Flex ActionScript, .Net,
PHP, and JAVA use scripted code. These are the most common forms
of coding.
Web Pages—Static to Dynamic
[ 14 ]
Now, we will look at decimal-based numbers. We will modify the code to show
some more things that you can do with numbers and to remove the string functions.
!--- Example: 1_4.cfm ---
!--- Processing ---
cfscript
myAge = 27;
halfAge = myAge/2;
/cfscript
!--- Content ---
cfoutput
myAge is (#myAge#)br /
halfAge is (#halfAge#)br /
halfAge rounded is (#round(halfAge)#)br /
4.2 rounded is (#round(4.2)#)br /
4.2 ceiling is (#ceiling(4.2)#)br /
/cfoutput
If you would like to have more information about the built-in functions, then you can
download the manuals in Appendix A and go through the PDF documents. You will
find that there are abundant built-in functions for application processing.
We have looked at creating a variable by using the value of another variable and by
changing the values of variables. You will find everything from modulo functions to
geometry functions for standard mathematical calculations. You will also find a rich
number of string functions that can help you process your pages.
The following piece of code will help you find the additional types of things that you
can do with strings:
!--- Example: 1_5.cfm ---
!--- Processing ---
cfscript
myQuestion = This is my question.;
myQuestion = myQuestion   Is THIS a string?;
location = find(this,myQuestion);
Chapter 1
[ 15 ]
/cfscript
!--- Content ---
cfoutput
myQuestion is (#myQuestion#)br /
Location of this is (#location#) characters from the start of the
string.br /
/cfoutput
You might be curious to know why the value of the find returned zero rather than
the actual position. You will notice that we changed the word this to THIS.
Computers see upper case letters differently from lower case letters. So THIS proved
the point that strings are case sensitive. Let us see how we can find an alternative
way with a ColdFusion's built-in function:
!--- Example: 1_6.cfm ---
!--- Processing ---
cfscript
myQuestion = This is my question.;
myQuestion = myQuestion   Is THIS a string?;
location = findNoCase(this,myQuestion);
location2 = findNoCase(this,myQuestion,location+1);
/cfscript
!--- Content ---
cfoutput
myQuestion is (#myQuestion#)br /
Location of this is (#location#) characters from the start of the
string.br /
The second this is located at position (#location2#).br /
/cfoutput
Web Pages—Static to Dynamic
[ 16 ]
Here, we did a couple of things. First, we made our string search case insensitive.
Then we added a second search to see if there were any more occurrences of the item
being searched for in the string variable. We added +1 to the location in order to
make sure that we skipped the first location in our search. It still returns the location
based on the start of the string irrespective of an in-depth search. The following code
shows the structure of the function that will help you understand the working of the
function documentation:
FindNoCase(substring, string, [start])
The arguments of the functions are required unless they are wrapped in [ ]. This
function searches for a substring inside string, optionally starting at start
number of characters into the string.
Understanding Structures
Structures are one of the most powerful variables that we will be looking at in
this book. An example is described that illustrates the working of the structure.
Structures are like files and folders on a computer file system. Folders can be empty
or they can contain multiple files or nested folders. Files may contain different types
of content. Yet, you can never call a folder directly and retrieve the actual file content
from a folder.
Structures in ColdFusion work along the same concepts����������������������
. Your structures can
be empty or they may contain both additional nested structures and variables
holding data.
Let us look at our first built-in structure type called CGI. We will take a look at
the most commonly used debugging tool for many developers. CGI is a collection
of variables that gives details about things ranging from the current request, the
browser of the requesting user, to information about the current running server.
It does not tell us everything, but it does provide us with good information so that
we may visit over and over again. All the structures start with a base structure
element. The CGI structure starts with cgi followed by a dot (.) with the structure
variable name:
cgi.structure_item_name
Chapter 1
[ 17 ]
Let us look at an easy way to see what is available. If you do this yourself, you can
scroll through and see how much information is offered. Here is the simple code.
You will also note that the pound symbols surround the variable name. This is
required for functions to work correctly. It may seem odd at first, but you will be
able to grasp it quickly even if you do not get it at the first glance:
!--- Example: 1_7.cfm ---
!--- Processing ---
!--- Content ---
cfdump var=#cgi#
The cfdump tag in ColdFusion takes any complex data type, and creates a grid or
nested grid if there is a nested structure to display the contents of the variable. Dump
allows us to see the state of a variable structure at a fixed point in the processing
cycle of our web page. There are options for not expanding, and for giving a label
to the dump for occasions when we may put more than one dump on a page during
the programming cycle. We will not want to use this type of function on final
production code because users might think that the system has crashed. When it
comes to programmers, this is one of the greatest, and it has been one of the features
of ColdFusion widely used by developers for many years. We will look at the end of
the page where we can see the server port, if the port was secure, and that there were
many other details with this dump.
Web Pages—Static to Dynamic
[ 18 ]
You will see everything from the cookie variables to the remote address of the
requesting user. If you were to access these directly in the code, you would have to
do it as follows. You will notice that the structure 'cgi', contains a good number of
variables. In this case, there are no nested structures but only variables. This makes
for a better introduction to the structures:
!--- Example: 1_8.cfm ---
!--- Processing ---
cfscript
requestedDomain = cgi.server_name;
isSecure = cgi.server_port_secure;
/cfscript
!--- Content ---
cfoutput
The requested domain was #requestedDomain#.br /
Was the current request secure (0 = No/1 = Yes) ? #isSecure# br /
/cfoutput
Let Us Get Interactive
We are going to get into a round trip interaction with web pages. This is the reason
why web programming beginners will agree as to why these web pages are known
as Dynamic Web Pages.
We will be learning a new structure called URL, and see one way to pass
information from the user back to the server. We will start by calling the same page
via the URL in order to understand this functionality. We will run the same code
twice. For the first time we will not pass any URL variables.
Chapter 1
[ 19 ]
As seen on the screen, our first example returned an empty structure. For the second
example run, you will see that we passed a URL variable called NAME with a value,
John. You can actually pass in many URL variables at the same time. This structure
works the same way as the CGI structure. We need to add name=John at the end of
the URL to get the structure. Here is the URL:
http://localhost/cfb/code/chapter_1/1_9.cfm?name=John
It does not contain any nested structure, so you could output the variable for name in
content as follows:
cfoutput
My name is #url.name#.
/cfoutput
Many of the failed web pages come when we start getting interactive. In addition to
having a look at the use of URL variables, we will take a brief look at how to catch
missing variables with the use of the URL variables. This is known as exception
handling in programming. Universally, the try catch method is used. This will be
visible in script usage, and in tag usage. This will also be an opportunity for you
to understand the concept of error or exception pages as you build ColdFusion
applications and you find that things are not working as planned.
Web Pages—Static to Dynamic
[ 20 ]
!--- Example: 1_10.cfm ---
!--- Processing ---
!--- Content ---
cfoutput
My name is #url.name#.br /
/cfoutput
We will start by running the page. In the URL type in the address followed by
?name=John. Type the URL precisely with the question mark. Here is the URL:
http://localhost/cfb/code/chapter_1/1_10.cfm?name=John
Now, we will intentionally generate our first error. Remove the question mark from
the end of the browser address box and the rest that follows it. Refresh the page.
Chapter 1
[ 21 ]
Many times, you will see the detailed information on the screen, as shown in the
earlier figure, when an error occurs. Not only did it tell us about the error but it also
showed us the line of code where the error occurred. Do not count on this to happen
all the time. By learning the use of the try catch block, the number of these issues will
be reduced. In our next version of code, you will see how the try catch block can be
used on the page to manage and help fix these errors:
!--- Example: 1_11.cfm ---
!--- Processing ---
!--- Content ---
cftry
cfoutput
My name is #url.name#.br /
/cfoutput
cfcatch
cfdump var=#cfcatch#
/cfcatch
/cftry
Here, the information is presented in a different manner but it gets you to the same
end. The exception is placed on the page using a cfdump tag. Most often, you
will find that this is the most useful approach to debugging. You can also email
the contents of the catch structure to an administrator. You may also note that the
StackTrace and objectType structure elements have been minimized. You toggle
elements in CFDump by clicking on the element text. This will hide all the nested
information until you desire to see it again.
Web Pages—Static to Dynamic
[ 22 ]
You might wonder why we included exception or error handling with CFDump. It is
because the results of the catch are stored in a variable called cfcatch that contains
a pleasant structure collection. Inside the structure, you will find a nested structure
called TagContext. Let us modify our code so that just one subset of this structure is
displayed on the screen. Change the cfdump to the following in your code:
cfdump var=#cfcatch.TagContext#
The structure allows us to drill down the pieces of information that we are interested
in without pulling the rest of the details along with them. We have not covered
arrays but you can drill down to the page where the problem occurred. We will learn
how arrays work in ColdFusion. But now, let us change the line of code once again,
and try:
cfdump var=#cfcatch.TagContext[1].template#
You will notice that the wrapper for our CFDump has disappeared. It has
disappeared because we are now outputting a simple variable. If there is no structure
or complex variable, then we get a simple variable where the CFDump is located on
the page. In this case, as the code error occurred at the end of the line, it will start
right from there, and this explains why it is on the same line as the web page content
in the browser.
Chapter 1
[ 23 ]
Setting Page Defaults
The information that you will obtain from here can be applied to more than page
defaults. This is the most common place where you should use it. We will make a
minor change in the code while creating a new page. We will use the� cfparam tag
to set the default values in the following code:
!--- Example: 1_12.cfm ---
!--- Processing ---
cfparam name=url.name default=( unknown user )
!--- Content ---
cftry
cfoutput
My name is #url.name#.br /
/cfoutput
cfcatch
cfdump var=#cfcatch#
/cfcatch
/cftry
Now, we have learned how to catch and handle exceptions. We have also learned
how to solve such types of error in ColdFusion. We created a default value for
this structure variable to prevent an error condition and handle it as a predictable
exception. If we add the name back to the URL, it will still work as expected.
Web Pages—Static to Dynamic
[ 24 ]
We have one more thing that can be done to understand the URL structure. We need
to add some standard browser links on the page, and then click on them to see what
happens. We will be creating two styles of links.
The first link will be a static link. This link will point back to our dynamic page to
show one form of interaction through URL variables:
!--- Example: 1_13.cfm ---
!--- Processing ---
cfparam name=url.name default=( unknown user )
!--- Content ---
cftry
cfoutput
My name is #url.name#.br /
a href=?name=TedShow this page with Ted for the name./abr /
a href=?name=FredShow this page with Fred for the name./a
br /
/cfoutput
cfcatch
cfdump var=#cfcatch#
/cfcatch
/cftry
Click on either of the links on the screen, and you will see that the variable stored
in the link is passed through the next time it loads from the server to the page. You
will also note that the address bar will display the variables passed in when the URL
requests to reload the pages. As displayed on the screen, we will click on� Fred to
try it.
Chapter 1
[ 25 ]
It will be clear that URL variables can come from more than one location. We have
seen their existence in the address bar, and in web page links.
Our final use of URL variables will involve some processing that is actually based on
the changes to the links that we click. Enter the following code:
!--- Example: 1_14.cfm ---
!--- Processing ---
cfparam name=url.counter default=10
cfparam name=url.calculate default=0
cfset url.counter += url.calculate
!--- Content ---
cfoutput
I have #url.counter# cars.br /
a href=?calculate=1counter=#url.counter#Add One./abr /
a href=?calculate=-1counter=#url.counter#Subtract One./abr /
/cfoutput
You can click on add and subtract as many times as you like to know if the page has
become very interactive. The counter is passed back with the counter change based
on the link that we click for the server from the web page. We had specified earlier
that to use the variables to create the content, we must wrap them inside a� CFOutput
tag pair, and surround the variables with pound symbols.
Web Pages—Static to Dynamic
[ 26 ]
This will be our last version of the script. It will be a bit more interesting than the
other scripts. We are going to create some custom structure, and detect how to
interact with that structure using what we have learned:
!--- Example: 1_15.cfm ---
!--- Processing ---
cfparam name=url.speed default=10
cfparam name=url.acceleration default=0
cfscript
myCar = structNew();
myCar.color = blue;
myCar.speed = url.speed + url.acceleration;
/cfscript
!--- Content ---
cfoutput
a href=?acceleration=-1speed=#myCar.speed#Slower/anbsp;
a href=?speed=#myCar.speed#Cruise/anbsp;
a href=?acceleration=1speed=#myCar.speed#Faster/abr /
cfdump var=#myCar# label=My Car
/cfoutput
We have learned that creating a new structure is done by assigning a value to
the variable using the function structNew(). You can nest structures inside the
structures in addition to actual variable storage containers. It is the first step towards
packaging your data inside the application. As applications grow, you will not want
to do everything with simple variables setting at the root level of your variable
structure. That would be impossible to maintain.
Another note is that we have persisted the values of the speed of the car by passing
through the URL variables. We will learn many interesting ways of making our
values exist from one page call to the next. We have learned how to use the structure,
and gained an understanding of the URL variables.
Chapter 1
[ 27 ]
Introduction to Lists and Loops
Lists are stored inside string variables. You can also have a list variable stored inside
a structure. Lists have a separator, which is commonly known as a� delimiter, to
divide the items, so the server can evaluate them. We are going to return to our FAQ
application concept and build on what we have learned. Let us look at the code
for lists.
!--- Example: 1_16.cfm ---
!--- Processing ---
cfparam name=url.speed default=10
cfparam name=url.acceleration default=0
cfscript
questions = What is the speed limit?,What is a car?,How much is
gas?;
/cfscript
!--- Content ---
cfoutput
The second question is:br /nbsp;nbsp;nbsp;
#listGetAt(questions,2)#
/cfoutput
You can see that the list has three items in it. We have the content request the second
item for display. The� listGetAt() function is one of the simple powerful functions
that make ColdFusion easy to program. You will find a number of astonishing list
functions built into the language. We will combine lists and loops so you can see
how things work together.
!--- Example: 1_17.cfm ---
!--- Processing ---
cfparam name=url.question default=What is the speed limit?
cfscript
questions = What is the speed limit?,What is a car?,How much is
gas?;
Web Pages—Static to Dynamic
[ 28 ]
answers = 55,Depends who you ask!,more than before;
myQuestion = listContains(questions,url.question);listContains(questi
ons,url.question);
/cfscript
!--- Content ---
cfoutput
strong#listGetAt(questions,myQuestion)#/strongbr /Answer:nbsp;
#listGetAt(answers,myQuestion)#br /br /
/cfoutput
All Questionshr /
cfloop list=#questions# index=iQuestionlist=#questions#
index=iQuestion
cfoutput
strongQ/strong: a href=?question=#iQuestion##iQuestion#/
abr /
/cfoutput
/cfloop
We made two lists this time, one list for questions known as questions, and another
for answers known as answers. When you build pairs of lists, check twice that they
have the same number of items to prevent errors. This will keep us away from the
debugging phase of development. If you look at where we assigned the numeric
value of� myQuestion, you will see that we are able to match the question asked in
the list. If there is an exact match, then the number of that item in the list is returned.
You will also observe that in the CFLoop list, the index variable contains the actual
item stored in that position in the list.
Chapter 1
[ 29 ]
Click on different questions, and see how things work. You will be able to see the
variables being passed in the address bar.
The listContains() function finds the accurate matches in a list. If
you want to find the first item in a list with a partial match, then use
ListFind(). Both of them have a NoCase version available.
We will continue to provide more information on loops as we get into arrays in
the next section. There are several types of loops, and these are among the most
preferred commands with ColdFusion developers.
Now, you have started to learn more about ColdFusion. Understand the finer points
by applying your knowledge.
Understanding Arrays
An array is an interesting variable construct. It is a collection of commonly named
variables with an index set. We will take the last code example and transfer it to
arrays. Here we will change the back end, but the front end will run in exactly the
same way, from a user's point of view. You will be able to see that we are now
passing a variable from page to page in the following code rather than the whole
questions as we did earlier.
!--- Example: 1_18.cfm ---
!--- Processing ---
cfparam name=url.question default=1
cfscript
question = arrayNew(1);
question[1] = What is the speed limit?;
question[2] = What is a car?;
question[3] = How much is gas?;
answer = arrayNew(1);
answer[1] = 55;
answer[2] = Depends who you ask!;
answer[3] = more than before;
/cfscript
!--- Content ---
cfoutput
strong#question[url.question]#/strongbr /Answer:nbsp;
#answer[url.question]#br /br /
/cfoutput
Web Pages—Static to Dynamic
[ 30 ]
All Questionshr /
cfloop from=1 to=#arrayLen(question)# index=iQuestion
cfoutput
strongQ/strong: a href=?question=#iQuestion##question[iQuest
ion]#/abr /
/cfoutput
/cfloop
We now have two array variable constructs. Before you start assigning variables
to an array, you need to declare the variable as an array type. Arrays can be multi-
dimensional. We will focus on a single-dimensional array. If you forget to pass the
number of dimensions when you declare an array, you will get an error when the
code runs. So, do remember to declare the number of dimensions.
The maximum number of dimensions in ColdFusion is three.
A large multi-dimensional array can consume huge amounts of
computer memory.
You will find a huge collection of array functions built into ColdFusion. You can
use arrayDeleteAt() to remove an item in the middle of an array. There is also
an arrayInsertAt() that does the reverse. The following three things are to be
observed while using arrays:
Items are not to be removed in the middle of an array list without using the
built-in functions. This could result in a missing element and an error can
occur when looping through the array collection.
An item is not to be counted while it is in the indexed position. It may seem
odd that we call the position of an index and think that the item can move.
This is different because arrays are dynamic.
The number of items in an array can change. The best way to do that is to use
the function arrayLen(), as we did in the example code to obtain the current
length of an array.
Now we will rewrite and run the same code as a multi-dimensional array. This is
also known as an array of structures. Each dimension of the array has a structure.
This allows for some unique layout of data within your application memory. We will
add a CFDump at the end of the code, and ��������������������������������������
view ���������������������������������
the structure created as follows:
!--- Example: 1_19.cfm ---
!--- Processing ---
cfparam name=url.faq default=1
cfscript
faq = arrayNew(1);
faq[1] = structNew();
•
•
•
Chapter 1
[ 31 ]
faq[1].question = What is the speed limit?;
faq[1].answer = 55;
faq[2] = structNew();
faq[2].question = What is a car?;
faq[2].answer = Depends who you ask!;
faq[3] = structNew();
faq[3].question = How much is gas?;
faq[3].answer = more than before;
/cfscript
!--- Content ---
cfoutput
strong#faq[url.faq].question#/strongbr /Answer:nbsp; #faq[url.
faq].answer#br /br /
/cfoutput
All Questionshr /
cfloop from=1 to=#arrayLen(faq)# index=iFAQ
cfoutput
strongQ/strong: a href=?faq=#iFAQ##faq[iFAQ].question#/abr
/
/cfoutput
/cfloop
cfdump var=#faq#
Web Pages—Static to Dynamic
[ 32 ]
We have gone through what you can do with structures, arrays, and loops.
ColdFusion ����������������������������������������������������������������������
experts find creative uses for them. They are quite simple to use and
very flexible to implement.
Conditional Processing with If
Now, we have reached the last section of our quick introduction to ColdFusion. We
would be remiss if we were to forget conditional processing. There are two tags that
make the bulk of conditional processing in ColdFusion.
The first tag is cfIf. If you are familiar with any other programming language,
you will find this function as you expect. While coding with tags, the language
should be able to differentiate between tag braces, and greater than and lesser than
logic. In ColdFusion, this is done by replacing the greater than symbol with GT and
the lesser than symbol with� LT. We use GTE for greater than or equal to, and LTE for
lesser than or equal to. If something is equal, we can either use IS or EQ.
Now, let us look at something related to the code. What can we do to make sure that
someone does not play tricks with the URL, and make our page fail by changing the
URL variables? Let us put in some conditional processing to perform business logic
in the processing section:
!--- Example: 1_20.cfm ---
!--- Processing ---
cfparam name=url.faq default=1
cfscript
faq = arrayNew(1);
faq[1] = structNew();
faq[1].question = What is the speed limit?;
faq[1].answer = 55;
faq[2] = structNew();
faq[2].question = What is a car?;
faq[2].answer = Depends who you ask!;
faq[3] = structNew();
faq[3].question = How much is gas?;
faq[3].answer = more than before;
/cfscript
cfif NOT isNumeric(url.faq)
cfset url.faq = 1
cfelse
cfset url.faq = round(url.faq)
cfif url.faq LT 1
cfset url.faq = 1
cfelseif url.faq GT arrayLen(faq)
Chapter 1
[ 33 ]
cfset url.faq = arrayLen(faq)
/cfif
/cfif
!--- Content ---
cfoutput
strong#faq[url.faq].question#/strongbr /Answer:nbsp; #faq[url.
faq].answer#br /br /
/cfoutput
All Questionshr /
cfloop from=1 to=#arrayLen(faq)# index=iFAQ
cfoutput
strongQ/strong: a href=?faq=#iFAQ##faq[iFAQ].question#
/abr /
/cfoutput
/cfloop
We will skip the screenshot because there is no change as to how the user sees the
page. The only difference is in the processing logic needed to prevent someone from
messing with the stability of the page. This will lay the foundation for protecting
things such as commerce pages.
Earlier, we forgot about the Boolean variable type. The conditional statements inside
the if statements evaluate to either true or false. These are the Boolean values. You
will also find that you can use either a zero, or a non-zero number to represent a
Boolean logical evaluation. Therefore, any expression that evaluates either to zero
or false has the same results. The other non-zero numbers and values such as true,
yes, and no are valid Boolean conditions. You can just take the same code and assign
it to a variable. Then you could use the variable inside the if statement instead
of evaluating the logic inside the statement. Normally, place it inside the� cfIf
statement, which is more meaningful.
cfset myBoolean = NOT isNumeric(url.faq)
We examine to make sure that the variable is a number. You are advised to change
the value in the address bar to text in order to prevent page breaks. You will find that
it selects the first item because the input in the URL variable is invalid���������������
. This is done
by using the logical condition NOT. The NOT condition takes the result of the test and
reverses it. You will notice that if this is not the condition used, then an alternative
set of code is processed:
cfif NOT isNumeric(url.faq)
We will attempt to break it by entering in a negative number, since there are no items
at that location in the array index, which would have led to page break. We have
prevented it with our conditional logic by resetting the value when any basic type of
hacking occurs.
Web Pages—Static to Dynamic
[ 34 ]
Let us take another look at the code with all the processing logic inside the CFScript.
The best part of the platform is that it is flexible; it can be done both ways:
!--- Example: 1_21.cfm ---
!--- Processing ---
cfparam name=url.faq default=1
cfscript
faq = arrayNew(1);
faq[1] = structNew();
faq[1].question = What is the speed limit?;
faq[1].answer = 55;
faq[2] = structNew();
faq[2].question = What is a car?;
faq[2].answer = Depends who you ask!;
faq[3] = structNew();
faq[3].question = How much is gas?;
faq[3].answer = more than before;
if(! isNumeric(url.faq))
{
url.faq = 1;
}
else
{
url.faq = round(url.faq);
if(url.faq  1)
{
url.faq = 1;
}
else if(url.faq  arrayLen(faq))
{
url.faq = arrayLen(faq);
}
}
/cfscript
We only show the top half of the code here, because the content section of the code
is identical to the previous example. You may notice that you can use some more
traditional script-style logic symbols while coding in script. Both these should help in
evaluating between syntax for the script and the syntax for the tag-based logic.
Chapter 1
[ 35 ]
Conditional Processing with Switch
You can achieve contextual selection of code segments with the cfIf tag, but the
cfSwitch tag �������������
has a unique style that will become a conditional processing favorite
in certain scenarios. In this section, we will restructure the FAQ example using the
switch statement logic. This is the best use of a switch statement, but it will help you
understand how the logic works. You will not see any difference when you look at
the browser from the user side.
!--- Example: 1_22.cfm ---
!--- Processing ---
cfparam name=url.faq default=
cfscript
faq = arrayNew(1);
faq[1] = structNew();
faq[1].question = What is the speed limit?;
faq[1].answer = 55;
faq[1].id = ‘a’;
faq[2] = structNew();
faq[2].question = What is a car?;
faq[2].answer = Depends who you ask!;
faq[2].id = ‘b’;
faq[3] = structNew();
faq[3].question = How much is gas?;
faq[3].answer = more than before;
faq[3].id = ‘c’;
/cfscript
cfswitch expression=#url.faq#
cfcase value=b
cfset question = faq[2].question
cfset answer = faq[2].answer
/cfcase
cfcase value=c
cfset question = faq[3].question
cfset answer = faq[3].answer
/cfcase
cfdefaultcase
cfset question = faq[1].question
cfset answer = faq[1].answer
/cfdefaultcase
/cfswitch
!--- Content ---
cfoutput
strong#question#/strongbr /Answer:nbsp; #answer#br /br /
Other documents randomly have
different content
ENTERTAINING A CHIPMUNK
CALLER
Once five callers came, each stringing in behind another. Just as
the fifth came in the door, there was a dispute among the others and
one started to retreat. Evidently he did not want to go, for he
retreated away from the open door. As number two started in pursuit
of him, number three gave chase to number two. After them started
number four, and the fifth one after all the others. The first one,
being closely pressed and not wanting to leave the room, ran round
the centre table, and in an instant all five were racing single file
round the table. After the first round they became excited and each
one went his best. The circle they were following was not large, and
the floor was smooth. Presently the rear legs of one skidded
comically, then the fore feet of another; and now and then one lost
his footing and rolled entirely over, then arose, looking surprised and
foolish, but with a leap entered the circle and was again at full
speed.
I enjoy having them about, and spend many a happy hour
watching them or playing with them. They often make a picnic-
ground of my porch, and now and then one lies down to rest upon
one of the log seats, where, outstretched, with head up and one
fore paw extended leisurely upon the log, he looks like a young lion.
Often they climb up and scamper over the roof of my cabin; but
most of their time on the roof is spent in dressing their fur or
enjoying long, warm sun baths. Frequently they mount the roof early
in the morning, even before sunrise. I am sometimes awakened at
early dawn by a chipmunk mob that is having a lively time upon the
roof.
In many things they are persistent. Once I closed the hole that
one had made in a place where I did not want it. I filled the hole full
of earth. Inside of two hours it was reopened. Then I pounded it full
of gravel, but this was dug out. I drove a stake into the hole. A new
hole was promptly made alongside the stake. I poured this full of
water. Presently out came a wet and angry chipmunk. This daily
drowning out by water was continued for more than a week before
the chipmunk gave it up and opened a hole about thirty feet distant.
For eight years I kept track of a chipmunk by my cabin. She lived
in a long, crooked underground hole, or tunnel, which must have
had a total length of nearly one hundred feet. It extended in a
semicircle and could be entered at three or four places through holes
that opened upon the surface. Each of these entrance holes was
partly concealed in a clump of grass by a cluster of plants or a
shrub.
I have many times examined the underground works of the
chipmunk. Some of these examinations were made by digging, and
others I traced as they were exposed in the making of large
irrigation ditches. The earth which is dug from these tunnels is
ejected from one or more holes, which are closed when the tunnel is
completed. Around the entrance holes there is nothing to indicate or
to publish their presence; and often they are well concealed.
These tunnels are from forty to one hundred feet long, run from
two to four feet beneath the surface, and have two or more
entrances. Here and there is a niche or pocket in the side of the
tunnel. These niches are from a few inches to a foot in diameter and
in height. In one or more of these the chipmunk sleeps, and in
others is stored his winter food-supply. He uses one of these pockets
for a time as a sleeping-place, then changes to another. This change
may enable the chipmunk to hold parasites in check. The fact that
he has a number of sleeping-places and also that in summer he
frequently changes his bedding, indicates that these efforts in
sanitation are essential for avoiding parasites and disease.
Commonly the bedding is grass, straw, and leaves; but in my yard
the chipmunks eagerly seize upon a piece of paper or a
handkerchief. I am compelled to keep my eyes open whenever they
come into the cabin, for they do not hesitate to seize upon
unanswered letters or incomplete manuscripts. In carrying off paper
the chipmunk commonly tears off a huge piece, crumples it into a
wad, and, with this sticking from his mouth, hurries away to his
bedchamber. It is not uncommon to see half a dozen at once in the
yard, each going his own way with his clean bed-linen.
Chipmunks take frequent dust and sun baths, but I have never
seen one bathe in water. They appear, however, to drink water
freely. One will sip water several times daily.
In the mountains near me the chipmunks spend from four to
seven months of each year underground. I am at an altitude of nine
thousand feet. Although during the winter they indulge in long
periods of what may be called hibernating sleep, they are awake a
part of the time and commonly lay in abundant stores for winter. In
the underground granaries of one I once found about a peck and a
half of weed seeds. Even during the summer the chipmunk
occasionally does not come forth for a day or two. On some of these
occasions I have found that they were in a heavy sleep in their beds.
These in my yard are fed so freely upon peanuts that they have
come to depend upon them for winter supplies. They prefer raw to
roasted peanuts. The chipmunk near my cabin sometimes becomes
a little particular and will occasionally reject peanuts that are handed
to her with the shell on. Commonly, however, she grabs the nut with
both fore paws, then, standing erect, rapidly bites away the shell
until the nut is reached. This she usually forces into her cheek
pocket with both hands. Her cheek pouches hold from twelve to
twenty of these. As soon as these are filled she hurries away to
deposit her stores in her underground granary. One day she
managed to store twenty-two, and her cheek pouches stood out
abnormally! With this swelled and uncouth head she hurried away
to deposit the nuts in her storehouse, but when she reached the
hole her cheeks were so distended that she was unable to enter.
After trying again and again she began to enlarge the hole. This she
presently gave up. Then she rejected about one third of the nuts,
entered, and stored the remainder. In a few minutes she was back
for more. One day she made eleven round trips in fifty-seven
minutes. Early one autumn morning a coyote, in attempting to reach
her, dug into her granary and scattered the nuts about. After
sending him off I gathered up three quarts of shelled nuts and left
about as many more scattered through the earth! Over these the
jays and magpies squabbled all day.
One day a lady who was unsympathetic with chipmunks was
startled by one of the youngsters, who scrambled up her clothes and
perched upon her head. Greatly excited, she gave wild screams. The
young chipmunk was in turn frightened, and fled in haste. He took
consolation with his mother several yards away. She, standing erect,
received him literally with open arms. He stood erect with one arm
upon her shoulder, while she held one arm around him. They thus
stood for some seconds, he screeching a frightened cry, while she,
with a subdued muttering, endeavored to quiet him.
Once, my old chipmunk, seeing me across the yard, came
bounding to me. Forgetting, in her haste, to be vigilant, she ran into
a family of weasels, two old and five young ones, who were crossing
the yard. Instantly, and with lion-like ferocity, the largest weasel
leaped and seized the chipmunk by the throat. With a fiendish jerk
of his head the weasel landed the chipmunk across his shoulders
and, still holding it by the throat, he forced his way, half swimming,
half floundering, through a swift brook which crossed the yard. His
entire family followed him. Most savagely did he resent my
interference when I compelled him to drop the dead chipmunk.
The wise coyote has a peculiar habit each autumn of feasting
upon chipmunks. Commonly the chipmunks retire for the winter
before the earth is frozen, or before it is frozen deeply. Apparently
they at once sink into a hibernating sleep. Each autumn, shortly
after the chipmunks retire, the coyotes raid all localities in my
neighborhood in which digging is good. Scores of chipmunks are dug
out and devoured. Within a quarter of a mile of my cabin one
October night forty-two holes were dug. Another night fifty-four
holes were dug near by. In a number of these a few scattered drops
of blood showed that the coyote had made a capture. In one week
within a few miles of my cabin I found several hundred freshly dug
holes. Many holes were dug directly down to the granary where the
stores were scattered about; and others descended upon the pocket
in which the chipmunk was asleep. In a few places the digging
followed along the tunnel for several yards, and in others the coyote
dug down into the earth and then tunneled along the chipmunk's
tunnel for several feet before reaching the little sleeper.
So far as I know, each old chipmunk lives by itself. It is, I think,
rare for one to enter the underground works of another. Each
appears to have a small local range upon the surface, but this range
is occasionally invaded by a neighboring chipmunk. This invasion is
always resented, and often the invader is angrily ejected by the local
claimant of the territory.
In my locality the young are born during the first week in June.
The five years that I kept track of the mother chipmunk near my
cabin, she usually brought the youngsters out into the sunlight about
the middle of June. Three of these years there were five youngsters.
One year the number was four, and another year it was six. About
the middle of July the young were left to fight the battle of life
alone. They were left in possession of the underground house in
which they were born, and the mother went to another part of the
yard, renovated another underground home, and here laid up
supplies for the winter.
A few days before the mother leaves the youngsters, they run
about and find most of their food. One year, a day or two before the
one by my cabin bade her children good-bye, she brought them—or,
at any rate, the children came with her—to the place where we often
distributed peanuts. The youngsters, much lighter in color, and less
distinctly marked than the mother, as well as much smaller, were
amusingly shy, and they made comic shows in trying to eat peanuts.
They could not break through the shell. If offered a shelled nut, they
were as likely to bite the end of your finger as the nut. They had not
learned which was which. With their baby teeth they could eat but
little of the nut, but they had the storing instinct and after a struggle
managed to thrust one or two of the nuts into their cheek pockets.
The youngsters, on being left to shift for themselves, linger about
their old home for a week or longer, then scatter, each apparently
going off to make an underground home for himself. The house may
be entirely new or it may be an old one renovated.
I do not know just when the mother returns to her old home.
Possibly the new home is closely connected with the one she has
temporarily left, and it may be that during the autumn or the early
spring she digs a short tunnel which unites them. The manner of this
aside, I can say that each summer the mother that I watched, on
retiring from the youngsters, carried supplies into a hole which she
had not used before, and the following spring the youngsters came
forth from the same hole, and presumably from the same quarters,
that the children of preceding years had used.
Chipmunks feed upon a variety of plants. The leaves, seeds, and
roots are eaten. During bloom time they feast upon wild flowers.
Often they make a dainty meal off the blossoms of the fringed blue
gentian, the mariposa lily, and the harebell. Commonly, in gathering
flowers, the chipmunk stands erect on hind feet, reaches up with
one or both hands, bends down the stalk, leisurely eats the
blossoms, and then pulls down another. The big chipmunk, however,
has some gross food habits. I have seen him eating mice, and he
often catches grasshoppers and flies. It is possible that he may rob
birds' nests, but this is not common and I have never seen him do
so. However, the bluebirds, robins, and red-winged blackbirds near
me resent his close approach. A chipmunk which has unwittingly
climbed into a tree or traveled into a territory close to the nest of
one of these birds receives a beating from the wings of the birds and
many stabs from their bills before he can retreat to a peaceful zone.
Many times I have seen birds battering him, sometimes repeatedly
knocking him heels over head, while he, frightened and chattering,
was doing his best to escape.
There are five species of chipmunks in Colorado. Two of these are
near me,—the big chipmunk and the busy chipmunk. The latter is
much smaller, shyer, and more lively than the former and spends a
part of its time in the treetops; while the big, although it sometimes
climbs, commonly keeps close to the earth.
Among their numerous enemies are coyotes, wild-cats, mountain
lions, bears, hawks, and owls. They appear to live from six to twelve
years. The one near my place I watched for eight years. She
probably was one or more years of age when I first saw her.
Almost every day in summer a number of children come, some of
them for miles, to watch and to feed my chipmunks. The children
enjoy this as keenly as I have ever seen them enjoy anything. Surely
the kindly sympathies which are thus aroused in the children, and
the delightful lesson in natural history which they get, will give a
helpful educational stimulus, and may be the beginning of a
sympathetic interest in every living thing.
A Peak by the Plains
A Peak by the Plains
Pike's Peak rises boldly from the plains, going steeply up into the
sky a vertical mile and a half. There is no middle distance or
foreground; no terraced or inclined approach. A spectator may thus
stand close to its foot, at an altitude of six thousand feet, and have a
commanding view of the eight thousand feet of slopes and terraces
which culminate in the summit, 14,110 feet above the sea. Its steep,
abrupt ascent makes it imposing and impressive. It fronts the wide
plains a vast broken tower. The typical high peak stands with other
high peaks in the summit of a mountain-range. Miles of lesser
mountains lie between its summit and the lowlands. Foothills rise
from the edge of the lowland; above these, broken benches, terrace
beyond terrace, each rising higher until the summit rises supreme.
With Pike's Peak this typical arrangement is reversed.
Pike's Peak probably is the most intimately known high mountain.
It has given mountain-top pleasure to more people than any other
fourteen thousand foot summit of the earth. One million persons
have walked upon its summit, and probably two million others have
climbed well up its slopes. Only a few thousand climbers have
reached the top of Mont Blanc. Pike's is a peak for the multitude.
PIKE'S PEAK FROM THE TOP OF CASCADE
CAÑON
Climbing it is comparatively easy. It stands in a mild, arid climate,
and has scanty snowfall; there are but few precipitous walls, no
dangerous ice-fields; and up most of its slopes any one may ramble.
One may go up on foot, on horseback, in a carriage, or by railroad,
or even by automobile. It is not only easy of ascent, but also easy of
access. It is on the edge of the plains, and a number of railroads
cross its very foot.
This peak affords a unique view,—wide plains to the east, high
peaks to the west. Sixty thousand or more square miles are visible
from the summit. It towers far above the plains, whose streams,
hills, and level spaces stretch away a vast flat picture. To the west it
commands a wondrous array of mountain topography,—a two-
hundred-mile front of shattered, snow-drifted peaks.
The peak is an enormous broken pyramid, dotted with high-
perched lakes, cut with plunging streams, broken by cañons, skirted
with torn forests, old and young, and in addition is beautiful with
bushes, meadows, and wild flowers. The major part of the peak's
primeval forest robe was destroyed by fire a half-century ago. Many
ragged, crag-torn areas of the old forest, of a square mile or less,
are connected with young growths from thirty to sixty years old.
Much of this new growth is aspen. From the tree-studies which I
have made, I learn that two forest fires caused most of the
destruction. The annual rings in the young growth, together with the
rings in the fire-scarred trees which did not perish, indicate that the
older and more extensive of these fires wrapped most of the peak in
flames and all of it in smoke during the autumn of 1850. The other
fire was in 1880.
Pike's Peak exhibits a number of scenic attractions and is bordered
by other excellent ones. Near are the Royal Gorge, Cripple Creek,
and the fossil-beds at Florissant. The Garden of the Gods, Manitou
Mineral Springs, Glen Eyrie, Crystal Park, the Cave of the Winds, and
Williams, Ruxton, and South Cheyenne Cañons are some of its
attractions.
The fossil-beds at Florissant are one of the most famous of fossil-
deposits. Here was an old Tertiary lake-basin. In the deposit which
filled it—a deposit of fine volcanic sand or ash, sediment, and other
débris—is a wonderful array of fossilized plants and insects of a past
age. All are strangely preserved for us in stone. A part of the lake
appears to have been filled by a volcanic catastrophe which
overwhelmed animals, plants, and insects. Whole and in fragments,
they are lying where they fell. Here have been found upwards of one
hundred recognizable plants, eleven vertebrate animals, and a few
hundred insects. Among the fossil trees are the narrow-leaf
cottonwood, the ginkgo, the magnolia, the incense cedar, and the
giant redwood. Water erosion through the ages has cut deeply into
these fossil-beds and worn and washed away their treasures. This
deposit has been but little studied. But what it has yielded, together
with the magnitude of the unexamined remainder, makes one eager
concerning the extent and the nature of the treasures which still lie
buried in it.
Helen Hunt, whose books helped awaken the American people to
the injustice done the Indian and to an appreciation of the scenic
grandeur of the West, lived for many years at the foot of this peak.
Much of her writing was done from commanding points on the peak.
She was temporarily buried on Cheyenne Mountain, and on her
former grave has accumulated a large cairn of stones, contributed
singly by appreciative pilgrims.
South Cheyenne Cañon, like Yosemite, gives a large, clear, and
pleasing picture to the mind. This is due to the individuality and the
artistic grouping of the beauty and grandeur of the cañon. The
cañon is so narrow, and its high walls so precipitous, that it could
justly be called an enormous cleft. At one point the walls are only
forty feet apart; between these a road and a swift, clear stream are
crowded. Inside the entrance stand the two Pillars of Hercules.
These magnificent rock domes rise nearly one thousand feet, and
their steep, tree-dotted walls are peculiarly pleasing and impressive.
Prospect Dome is another striking rock point in this cañon. The
cañon ends in a colossal cirque, or amphitheatre, about two hundred
and fifty feet deep. Down one side of this a stream makes its seven
white zigzag jumps.
Pike's Peak wins impressiveness by standing by itself. Cheyenne
Cañon is more imposing by being alone,—away from other cañons.
This cañon opens upon the plains. It is a cañon that would win
attention anywhere, but its situation is a most favorable one. Low
altitude and a warm climate welcome trees, grass, bushes, and
many kinds of plants and flowers. These cling to every break, spot,
ledge, terrace, and niche, and thereby touch and decorate the
cañon's grim and towering walls with lovely beauty. Walls, water, and
verdure—water in pools and falls, rocks in cliffs, terraces, and
domes, grass and flowers on slopes and terraces, trees and groves,
—a magnificence of rocks, a richness of verdure, and the charm of
running water—all unite in a picturesque association which makes a
glorious and pleasing sunken garden.
It is probable that Pike's Peak was discovered by Spanish explorers
either in 1598 or in 1601. These are the dates of separate exploring
expeditions which entered Colorado from the south and marched up
the plains in near view of this peak. The discovery is usually
accredited, however, to Lieutenant Pike, who caught sight of it on
the 15th day of November, 1806. Pike's journal of this date says: At
two o'clock in the afternoon I thought I could distinguish a mountain
to our right which appeared like a small blue cloud; viewed it with a
spyglass and was still more confirmed in my conjecture.... In half an
hour it appeared in full view before us. When our small party arrived
on a hill, they with one accord gave three cheers to the Mexican
Mountains. It appears not to have been called Pike's Peak until
about twenty-five years after Pike first saw it. He spoke of it as the
Mexican Mountains and as Great Peak. The first ascent by white men
was made July 14, 1819, by members of Lieutenant Long's exploring
expedition. For a number of years this peak was called James Peak,
in honor of the naturalist in the Long exploring party.
Pike's Peak has what Montesquieu calls the most powerful of all
empires, the empire of climate. It stands most of the time in the
sun. All over it the miner and the prospector have searched for gold,
mutilating it here and there with holes. Fires have scarred the sides,
and pasturing has robbed it of flowers and verdure. The reputed
discovery of gold at its base started a flood of gold-seekers west
with Pike's Peak or bust enthusiasm. But the climate and scenery
of this peak attract people who come for pleasure and to seek for
health. It has thus brought millions of dollars into Colorado, and it
will probably continue to attract people who seek pleasure and
refreshment and who receive in exchange higher values than they
spend. Pike's Peak is a rich asset.
The summit of Pike's Peak is an excellent place to study the effect
of altitude upon lowland visitors. Individual observations and the
special investigations of scientific men show that altitude has been a
large, unconscious source of nature-faking. During the summer of
1911 a number of English and American scientists, the Anglo-
American Expedition, spent five weeks on Pike's Peak, making
special studies of the effects of altitude. Their investigations explode
the theory that altitude is a strain upon the heart, or injurious to the
system. These men concluded that the heart is subjected to no
greater strain in high altitudes than at sea-level, except under the
strain of physical exertion. The blood is richer in high altitudes. For
every hundred red corpuscles found at sea-level there are in
Colorado Springs, at six thousand feet, one hundred and ten; and on
the summit of Pike's Peak, from one hundred and forty to one
hundred and fifty-four.
The danger to people suffering from heart trouble coming into
high altitudes is grossly exaggerated, says Dr. Edward C. Schneider,
one of the Anglo-American expedition. The rate of circulation is not
materially increased. The blood-pressure on the Peak is not
increased; it is even lowered. The heart—if a person exercises—may
beat a little faster but it does not pump any more blood. The pulse is
a little more rapid. If a man suffering from heart trouble rode up the
peak on a train, remained in his seat, and did not exert himself
physically, his heart would not beat a bit faster at the summit than
when he left Manitou. But if he walked about on the summit there
would be a change, for the exercise would make the heart work
harder. But exercise is not injurious; it is beneficial.
As I found in guiding on Long's Peak, the rarefied air of the
heights was often stimulating, especially to the tongue. Rarefied air
is likened by the scientists to laughing-gas and furnishes a
plausible explanation of the queerness which characterizes the
action of many people on mountain-summits. We saw many visitors
at the summit, said Dr. Schneider in explaining this phase, who
appeared to be intoxicated. But there was no smell of liquor on their
breath. They were intoxicated with rarefied atmosphere, not with
alcohol. The peculiar effects of laughing-gas and carbon-monoxide
gas on people are due to the lack of oxygen in the gas; and the
same applies to the air at high altitudes.
The summit of Pike's Peak is roomy and comparatively level, and is
composed of broken granite, many of the pieces being of large size.
A stone house stands upon the top. In this for many years was a
government weather-observer. A weather station has just been re-
established on its summit. This will be one of a line of high weather
stations extending across the continent. This unique station should
contribute continuously to the weather news and steadily add to the
sum of climatic knowledge.
This one peak has on its high and broken slopes a majority of the
earth's climatic zones, and a numerous array of the earth's countless
kinds of plant and animal life. One may in two hours go from base to
summit and pass through as many life zones as though he had
traveled northward into the Arctic Circle. Going from base to summit,
one would start in the Upper Sonoran Zone, pass through the
Transition, Canadian, and Hudsonian Zones, and enter the Arctic-
Alpine Zone. The peak has a number of places which exhibit the
complexity of climatic zones. In a deep cañon near Minnehaha Falls,
two zones may be seen side by side on opposite sides of a deep,
narrow cañon. The north side of the cañon, exposed to the sun, has
such plants as are found in the Transition Zone, while the cool south
side has an Hudsonian flora. Here is almost an actual contact of two
zones that outside the mountains are separated by approximately
two thousand miles.
The varied climate of this peak makes a large appeal to bird-life.
Upward of one hundred species are found here. People from every
part of the Union are here often startled by the presence of birds
which they thought were far away at home. At the base the
melodious meadowlark sings; along the streams on the middle
slopes lives the contented water-ouzel. Upon the heights are the
ptarmigan and the rosy finch. Often the golden eagle casts his
shadow upon all these scenes. The robin is here, and also the
bluebird, bluer, too, than you have ever seen him. The Western
evening grosbeak, a bird with attractive plumage and pleasing
manners, often winters here. The brilliant lazuli bunting, the Bullock
oriole, the red-shafted flicker, and the dear and dainty goldfinch are
present in summer, along with mockingbirds, wrens, tanagers,
thrushes, and scores of other visitants.
A few migratory species winter about the foot of the peak. In
summer they fly to the upper slopes and nest and raise their young
in the miniature arctic prairies of the heights. With the coming of
autumn all descend by easy stages to the foot. The full distance of
this vertical migration could be covered in an hour's flight. Many of
the north-and-south-migrating birds travel a thousand times as far
as these birds of vertical migration.
The big game which formerly ranged this peak included buffalo,
deer, elk, mountain sheep, the grizzly, the black bear, the mountain
lion, the fox, the coyote, and the wolf. Along the descending
streams, through one vertical mile of altitude, were beaver colonies,
terrace upon terrace. No one knows how many varieties of wild
flowers each year bloom in all the Peak's various ragged zones, but
there are probably no fewer than two thousand. Along with these
are a number of species of trees. Covering the lower part of the
mountain are growths of cottonwood, Douglas spruce, yellow pine,
white fir, silver spruce, and the Rocky Mountain birch. Among the
flowering plants are the columbine, shooting-star, monkshood, yucca
or Spanish bayonet, and iris. Ascending, one finds the wintergreen, a
number of varieties of polemonium, the paintbrush, the Northern
gentian, the Western yarrow, and the mertensia. At timber-line, at
the altitude of about eleven thousand five hundred feet, are
Engelmann spruce, arctic willow, mountain birch, foxtail pine, and
aspen. At timber-line, too, are the columbine, the paintbrush, and a
number of species of phlox. There are no trees in the zone which
drapes the uppermost two thousand feet of the summit, but in this
are bright flowers,—cushion pinks, the spring beauty, the alpine
gentian, the mountain buckwheat, the white and yellow mountain
avens, the arctic harebell, the marsh-marigold, the stonecrop, and
the forget-me-not. One summer I found a few flowers on the
summit.
Isolation probably rendered the summit of this peak less favorable
for snow-accumulation during the Ice Age than the summits of
unisolated peaks of equal altitude. During the last ice epoch,
however, it carried glaciers, and some of these extended down the
slopes three miles or farther. These degraded the upper slopes,
moved this excavated material toward the bottom, and spread it in a
number of places. There are five distinct cuplike hollows or
depressions in this peak that were gouged by glaciers. The one lying
between Cameron's Cone and the summit is known as the Crater.
A part of this is readily seen from Colorado Springs. Far up the
slopes are Lake Moraine and Seven Lakes, all of glacial origin.
The mountain mass which culminates in Pike's Peak probably
originated as a vast uplift. Internal forces appear to have severed
this mass from its surroundings and slowly upraised it seven
thousand or more feet. The slow uprising probably ended thousands
of years ago. Since that time, disintegration, frost, air, and stream
erosion have combined to sculpture this great peak. Pike's Peak
might well be made a National Park.
The Conservation of Scenery
The Conservation of
Scenery
The comparative merits of the Alps and the Rocky Mountains for
recreation purposes are frequently discussed. Roosevelt and others
have spoken of the Colorado Rockies as The Nation's Playground.
This Colorado region really is one vast natural park. The area of it is
three times that of the Alps. The scenery of these Colorado Rocky
Mountains, though unlike that of the Alps, is equally attractive and
more varied. Being almost free from snow, the entire region is easily
enjoyed; a novice may scale the peaks without the ice and snow that
hamper and endanger even the expert climbers in the icy Alps. The
Alps wear a perpetual ice-cap down to nine thousand feet. The
inhabited zone in Colorado is seven thousand feet higher than that
zone in Switzerland. At ten thousand feet and even higher, in
Colorado, one finds railroads, wagon-roads, and hotels. In
Switzerland there are but few hotels above five thousand feet, and
most people live below the three-thousand-foot mark. Timber-line in
Colorado is five thousand feet farther up the heights than in
Switzerland. The Centennial State offers a more numerous and
attractive array of wild flowers, birds, animals, and mineral springs
than the land of William Tell. The Rocky Mountain sheep is as
interesting and audacious as the chamois; the fair phlox dares
greater heights than the famed edelweiss. The climate of the Rocky
Mountains is more cheerful than that of the Alps; there are more
sunny days, and while the skies are as blue as in Switzerland, the air
is drier and more energizing.
THE CONTINENTAL DIVIDE NEAR ESTES
PARK
But the attractions in the Alps are being preserved, while the
Rocky Mountains are being stripped of their scenery. Yet in the
Rocky Mountains there are many areas rich in perishable attractions
which might well be reserved as parks so that their natural beauties
could be kept unmarred. It is to be hoped that the growing interest
in American scenery will bring this about before these wild mountain
gardens are shorn of their loveliness.[1]
[1] Since this was put into type, the Rocky Mountain National
Park, after a campaign of six years, has been established, and
campaigns have started to make National Parks of Mount Evans
and Pike's Peak. And the Secretary of the Interior has appointed a
Superintendent of National Parks and called attention to the great
need of legislation for these Parks.
The United States is behind most nations in making profitable use
of scenery. Alpine scenery annually produces upward of ten
thousand dollars to the square mile, while the Rocky Mountains are
being despoiled by cattle and sawmills for a few dollars a square
mile. Though Switzerland has already accomplished much along
scenic conservation lines, it is working for still better results. It is
constructing modern hotels throughout the Alps and is exploiting the
winter as well as the summer use of these. The Canadian
Government has done and is doing extensive development work in
its national parks. It is preparing a welcome for multitudes of
travelers; travelers are responding in numbers.
The unfortunate fact is that our scenery has never had a standing.
To date, it has been an outcast. Often lauded as akin to the fine
arts, or something sacred, commonly it is destroyed or put to base
uses. Parks should no longer be used as pigpens and pastures.
These base uses prevent the parks from paying dividends in
humanity.
There is in this country a splendid array of Nature's masterpieces
to lure and reward the traveler. In mountain-peaks there are Grand
Teton, Long's Peak, Mt. Whitney, and Mt. Rainier; in cañons, the vast
Grand Cañon and the brilliantly colored Yellowstone; in trees, the
unrivaled sequoias and many matchless primeval forests; in rivers,
few on earth are enriched with scenes equal to those between which
rolls the Columbia; in petrified forests, those in Arizona and the
Yellowstone are unsurpassed; in natural bridges, those in Utah easily
arch above the other great ones of the earth; in desert attractions,
Death Valley offers a rare display of colors, strangeness, silences,
and mirages; in waterfalls, we have Niagara, Yellowstone, and
Yosemite; in glaciers, there are those of the Glacier and Mount
Rainier National Parks and of Alaska; in medicinal springs, there is
an array of flowing, life-extending fountains; in wild flowers, the
mountain wild flowers in the West are lovely with the loveliest
anywhere; in wild animals of interest and influence, we have the
grizzly bear, the beaver, and the mountain sheep; in bird music, that
which is sung by the thrushes, the cañon wren, and the solitaire
silences with melodious sweetness the other best bird-songs of the
earth. In these varied attractions of our many natural parks we have
ample playgrounds for all the world and the opportunity for a travel
industry many times as productive as our gold and silver mines—and
more lasting, too, than they. When these scenes are ready for the
traveler we shall not need to nag Americans to see America first;
and Europeans, too, might start a continuous procession to these
wonderlands.
In the nature of things, the United States should have a travel
industry of vast economic importance. The people of the United
States are great travelers, and we have numerous and extensive
scenic areas of unexcelled attractiveness, together with many of the
world's greatest natural wonders and wonderlands which every one
wants to see. All these scenes, too, repose in a climate that is
hospitable and refreshing. They should attract travelers from abroad
as well as our own people. The traveler brings ideas as well as gold.
He comes with the ideals of other lands and helps promote
international friendship. Then, too, he is an excellent counter-irritant
to prevent that self-satisfied attitude, that deadening provincialism,
which always seems to afflict successful people. Develop our parks
by making them ready for the traveler, and they will become
continuously productive, both commercially and spiritually.
Our established scenic reservations, or those which may be
hereafter set aside, are destined to become the basis of our large
scenic industry. The present reservations embrace fourteen National
Parks and twenty-eight National Monuments. Each Park and
Monument was reserved because of its scenic wonders, to be a
recreation place for the people. The name Monument might well be
changed to Park. The Monuments were set aside by executive orders
of the President; the Parks were created by acts of Congress. Each
Park or Monument is a wonderland in itself. All these together
contain some of the strangest, sublimest scenes on the globe. Each
reservation is different from every other, and in all of them a traveler
could spend a lifetime without exhausting their wonders.
I suppose that in order to lead Americans to see America first, or
to see it at all, and also to win travel from Europe, it is absolutely
necessary to get America ready for the traveler. Only a small part of
American scenery is ready for the traveler. The traveler's ultimatum
contains four main propositions. These are grand scenery, excellent
climate, good entertainment, and swift, comfortable transportation.
When all of these demands are supplied with a generous horn of
plenty, then, but not until then, will multitudes travel in America.
Parks now have a large and important place in the general
welfare, and the nation that neglects its parks will suffer a general
decline. The people of the United States greatly need more parks,
and these are needed at once. I do not know of any city that has
park room extensive enough to refresh its own inhabitants. Is there
a State in the Union that has developed park areas that are large
enough for the people of the State? With present development, our
National Parks cannot entertain one fifth of the number of Americans
who annually go abroad. As a matter of fact, the entertainment
facilities in our National Parks are already doing a capacity business.
How, then, can our Parks be seen by additional travelers?
For a travel industry, the present needs in America are for cities at
once to acquire and develop into parks all near-by scenery; for each
State to develop its best scenic places as State Parks; and for the
nation to make a number of new National Parks and at once make
these scenic reservations ready for the traveler. Systems of good
roads and trails are necessary. In addition to these, the Parks,
Monuments, and Reservations need the whole and special attention
of a department of their own.
A park requires eternal vigilance. The better half of our scenic
attractions are the perishable ones. The forests and the flowers, the
birds and the animals, the luxuriant growths in the primeval wild
gardens, are the poetry, the inspiration, of outdoors. Without these,
how dead and desolate the mountain, the meadow, and the lake! If
a park is to be kept permanently productive, its alluring features
must be maintained. If the beaver ceases to build his picturesque
home, if the deer vanishes, if the mountain sheep no longer poses
on the crags, if the columbine no longer opens its bannered bosom
to the sun, if the solitaire no longer sings,—without these poetic and
primeval charms, marred nature will not attract nor refresh. People
often feel the call of the wild, and they want the wild world
beautiful. They need the temples of the gods, the forest primeval,
and the pure and flower-fringed brooks.
It would be well to save at once in parks and reservations the
better of all remaining unspoiled scenic sections of the country,—the
lake-shores and the seashore, the stream-side, the forests primeval,
and the Rocky Mountains. There is a great and ragged scenic border
of varying width that extends entirely around the United States. This
includes the Great Lake region and the splendid Olympic Mountains
at the northwest corner of the country. Inside of this border are
other localities richly dowered with natural beauty and dowered, too,
with hospitable climate. The Rocky Mountain region is one splendid
recreation-ground. There are many beauty-spots in the Ozark
Mountains of Missouri and Arkansas, and there are scenic regions in
New York, Pennsylvania, and western North Carolina, and the State
of Idaho embraces many scenic empires. These contain scores of
park areas that will early be needed.
LONG'S PEAK FROM LOCH
VALE
Every park is a place of refuge, a place wherein wild life thrives
and multiplies. As hunters are perpetually excluded from all parks,
these places will thus become sanctuaries for our vanishing wild life.
All wild life quickly loses its fear and allows itself to be readily seen
in protected localities. Wild life in parks thus affords enjoyment by
being readily seen, and from now on this life will become a factor in
education. Children who go into parks will be pleasantly compelled
to observe, delightfully incited to think, and will thus become alert
and interested,—will have the very foundation of education. Perhaps
it is safe to predict that from now on the tendency will be to multiply
the number of parks and decrease the number of zoölogical gardens.
Scenic places, if used for parks, will pay larger returns than by any
other use that can be made of their territory. Parks, then, are not a
luxury but a profitable investment. Switzerland is supporting about
half of her population through the use of her mountain scenery for
recreation purposes. Although parks pay large dividends, they also
have a higher, nobler use. They help make better men and women.
Outdoor life is educational. It develops the seeing eye, supplies
information, gives material for reflection, and compels thinking,
which is one of the greatest of accomplishments. Exercise in the
pure air of parks means health, which is the greatest of personal
resources, and this in turn makes for efficiency, kindness,
hopefulness, and high ideals. Recreation in parks tends to prevent
wasted life by preventing disease and wrong-doing. The
conservation of scenery, the use of scenic places for public
recreation parks, is conservation in the highest sense, for parks
make the best economic use of the territory and they also pay large
dividends in humanity.
The travel industry is a large and direct contributor to many
industries and their laborers. It helps the railroads, automobile-
makers, hotels, guides, and the manufacturers of the clothing,
books, souvenirs, and other articles purchased by travelers. Perhaps
the farmer is the one most benefited; he furnishes the beef, fruit,
butter, chickens, and in fact all the food consumed by the traveling
multitude. A large travel industry means enlarging the home market
to gigantic proportions.
The courts have recently expressed definite and advanced views
concerning scenic beauty. In Colorado, where water has a high
economic value, a United States Circuit Court recently decided that
the beneficial use of a stream was not necessarily an agricultural,
industrial, or commercial use, and that, as a part of the scenery, it
was being beneficially used for the general welfare. The question
was whether the waters of a stream, which in the way of a lakelet
and a waterfall were among the attractions of a summer resort,
could be diverted to the detriment of the falls and used for power.
The judge said No, because the waters as used, were contributing
toward the promotion of the public health, rest, and recreation; and
that as an object of beauty—just to be looked at—they were not
running to waste but were in beneficial use. He held that objects of
beauty have an important place in our lives and that these objects
should not be destroyed because they are without assessable value.
The judge, Robert E. Lewis, said in part:—
It is a beneficial use to the weary that they, ailing and feeble, can
have the wild beauties of Nature placed at their convenient disposal.
Is a piece of canvas valuable only for a tentfly, but worthless as a
painting? Is a block of stone beneficially used when put into the
walls of a dam, and not beneficially used when carved into a piece of
statuary? Is the test dollars, or has beauty of scenery, rest,
recreation, health and enjoyment something to do with it? Is there
no beneficial use except that which is purely commercial? This
decision is epoch-marking.
Taken as a whole, our National Parks and Monuments and our
unreserved scenic places may be described as an undeveloped
scenic resource of enormous potential value. These places should be
developed as parks and their resources used exclusively for
recreation purposes. Thus used, they would help all interests and
reach all people. South America, Switzerland, Canada, and other
countries are making intensified and splendid use of their parks by
reserving that wild scenic beauty which appeals to all the world.
Parks are dedicated to the highest uses. They are worthy of our
greatest attentions. It is of utmost importance that the management
of Forest Reserves and the National Parks be separate. In 1897 the
National Academy of Sciences in submitting a plan for the
management of the Forest Reserves recommended that places
specially scenic be separated from the Forest Reserves and set aside
as Parks and given the separate and special administration which
parks need. If scenery is to be saved, it must be saved for its own
sake, on its own merits; it cannot be saved as something incidental.
Multitudes will annually visit these places, provided they be
developed as parks and used for people and for nothing else.
Grazing, lumbering, shooting, and other commercial, conflicting, and
disfiguring uses should be rigidly prohibited. Scenery, like beauty,
has superior merit, and its supreme use is by people for rest and
recreation purposes.
Switzerland after long experience is establishing National Parks
and giving these a separate and distinct management from her
forest reserves. For a time Canadian National Parks were managed
by the Forest Service. Recently, however, the parks were withdrawn
from the Forest Service and placed in a Park Department. This was a
most beneficial change. Forestry is commercial, radically utilitarian.
The forester is a man with an axe. Trees to the forester mean what
cattle do to the butcher. Lumber is his product and to recite
Woodman, Spare that Tree! to a forester would be like asking the
butcher to spare the ox. The forester is a scientific slaughterer of the
forest; he must keep trees falling in order to supply lumber. A
forester is not concerned with the conservation of scenery. Then,
too, a forester builds his roads to facilitate logging and lumbering.
The Park man builds roads that are scenic highways, places for
people.
We need the forest reserve, and we need the National Park. Each
of these serves in a distinct way, and it is of utmost importance that
each be in charge of its specialist. The forester is always the
lumberman, the park man is a practical poet; the forester thinks ever
of lumber, the park man always of landscapes. The forester must cut
trees before they are over-ripe or his crop will waste, while the park
man wants the groves to become aged and picturesque. The
forester pastures cattle in his meadows, while the park man has only
people and romping children among his wild flowers. The park needs
the charm of primeval nature, and should be free from ugliness,
artificiality, and commercialism. For the perpetuation of scenery, a
landscape artist is absolutely necessary. It would be folly to put a
park man in charge of a forest reserve, a lumbering proposition. On
the other hand, what a blunder to put a tree-cutting forester in
charge of a park! We need both these men; each is important in his
place; but it would be a double misfortune to put one in charge of
the work of the other. A National Park service is greatly needed.
Apparently William Penn was the first to honor our scenery, and
Bryant, with poetry, won a literary standing for it. Official recognition
came later, but the establishment of the Yellowstone National Park
was a great incident in the scenic history of America—and in that of
the world. For the first time, a scenic wonderland was dedicated as
a public park or pleasure ground for the benefit and enjoyment of
all the people. The Yellowstone stands a high tribute to the
statesmanship, the public spirit, and the energy of F. V. Hayden and
the few men who won it for us.
During the last few years the nation, as well as the courts, has put
itself on record concerning the higher worth of scenery. The White
House conference of governors recommended that the beauty ... of
our country should be preserved and increased; and the first
National Conservation Commission thought that public lands more
valuable for conserving ... natural beauties and wonders than for
agriculture should be held for the use of the people.
The travel industry benefits both parties,—the entertained as well
as the entertainer. Investments in outdoor vacations give large
returns; from an outing one returns with life lengthened, in livelier
spirits, more efficient, with new ideas and a broader outlook, and
more hopeful and kind. Hence parks and outdoor recreation places
are mighty factors for the general welfare; they assist in making
better men and women. A park offers the first aid and often the only
cure for the sick and the overworked. Looking upon our sublime
scenes arouses a love for our native land and promotes a fellow
feeling. Nature is more democratic even than death; and when
people mingle amid primeval scenes they become fraternal. Saving
our best scenes is the saving of manhood. These places encourage
every one to do his best and help all to live comfortably in a
beautiful world. Scenery is our noblest resource. No nation has ever
fallen from having too much scenery.
The Rocky Mountain National Park
The Rocky Mountain
National Park
Extend a straight line fifty-five miles northwest from Denver and
another line sixty miles southwest from Cheyenne and these lines
meet in approximately the centre of the Rocky Mountain National
Park. This centre is in the mountain-heights a few miles northwest of
Long's Peak, in what Dr. F. V. Hayden, the famous geologist, calls the
most rugged section of the Continental Divide of the Rocky
Mountains.
This Park is a mountain realm lying almost entirely above the
altitude of nine thousand feet. Through it from north to south
extends the Snowy Range,—the Continental Divide,—and in it this
and the Mummy Range form a vast mountain Y. Specimen Mountain
is the north end of the west arm of this Y, while Mummy Mountain is
at the tip of the east arm. Mt. Clarence King on the south forms the
base of the stem, while Long's Peak is against the eastern side of
the stem, about midway.
Welcome to our website – the perfect destination for book lovers and
knowledge seekers. We believe that every book holds a new world,
offering opportunities for learning, discovery, and personal growth.
That’s why we are dedicated to bringing you a diverse collection of
books, ranging from classic literature and specialized publications to
self-development guides and children's books.
More than just a book-buying platform, we strive to be a bridge
connecting you with timeless cultural and intellectual values. With an
elegant, user-friendly interface and a smart search system, you can
quickly find the books that best suit your interests. Additionally,
our special promotions and home delivery services help you save time
and fully enjoy the joy of reading.
Join us on a journey of knowledge exploration, passion nurturing, and
personal growth every day!
ebookbell.com

Coldfusion 8 Developer Tutorial John Farrar

  • 1.
    Coldfusion 8 DeveloperTutorial John Farrar download https://ebookbell.com/product/coldfusion-8-developer-tutorial- john-farrar-2087536 Explore and download more ebooks at ebookbell.com
  • 2.
    Here are somerecommended products that we believe you will be interested in. You can click the link to download. Coldfusion Mx Developers Handbook Raymond Camden Arman Danesh https://ebookbell.com/product/coldfusion-mx-developers-handbook- raymond-camden-arman-danesh-2005152 Coldfusion Mx Developers Cookbook Developers Library 1st Edition Peter Freitag https://ebookbell.com/product/coldfusion-mx-developers-cookbook- developers-library-1st-edition-peter-freitag-2178966 Voicexml 20 Developers Guide Building Professional Voiceenabled Applications With Jsp Asp Coldfusion 1st Dreamtech Software India https://ebookbell.com/product/voicexml-20-developers-guide-building- professional-voiceenabled-applications-with-jsp-asp-coldfusion-1st- dreamtech-software-india-2206386 Voicexml 20 Developers Guide Building Professional Voiceenabled Applications With Jsp Asp Coldfusion Dreamtech Software India https://ebookbell.com/product/voicexml-20-developers-guide-building- professional-voiceenabled-applications-with-jsp-asp-coldfusion- dreamtech-software-india-4110456
  • 3.
    Java For ColdfusionDevelopers 1st Eben Hewitt https://ebookbell.com/product/java-for-coldfusion-developers-1st-eben- hewitt-923390 Foundation Flex For Developers Datadriven Applications With Php Aspnet Coldfusion And Lcds 1st Edition Sas Jacobs https://ebookbell.com/product/foundation-flex-for-developers- datadriven-applications-with-php-aspnet-coldfusion-and-lcds-1st- edition-sas-jacobs-4164926 Macromedia Dreamweaver 8 With Asp Coldfusion And Php Training From The Source Jeffrey Bardzell https://ebookbell.com/product/macromedia-dreamweaver-8-with-asp- coldfusion-and-php-training-from-the-source-jeffrey-bardzell-1339386 Coldfusion Presents New Thinking From Einstein To Artificial Intelligence The Science And Technology That Transformed Our World Ebook Dagogo Altraide https://ebookbell.com/product/coldfusion-presents-new-thinking-from- einstein-to-artificial-intelligence-the-science-and-technology-that- transformed-our-world-ebook-dagogo-altraide-22683130 Coldfusion Mx Bible Adam Phillip Churvis Hal Helms Charles Arehart https://ebookbell.com/product/coldfusion-mx-bible-adam-phillip- churvis-hal-helms-charles-arehart-4566660
  • 6.
    ColdFusion 8 Developer Tutorial Anintense guide to creating professional ColdFusion web applications: get up to speed in ColdFusion and learn how to integrate with other web 2.0 technologies John Farrar BIRMINGHAM - MUMBAI
  • 7.
    ColdFusion 8 DeveloperTutorial Copyright © 2008 Packt Publishing All rights reserved. No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews. Every effort has been made in the preparation of this book to ensure the accuracy of the information presented. However, the information contained in this book is sold without warranty, either express or implied. Neither the author, Packt Publishing, nor its dealers or distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book. Packt Publishing has endeavored to provide trademark information about all the companies and products mentioned in this book by the appropriate use of capitals. However, Packt Publishing cannot guarantee the accuracy of this information. First published: June 2008 Production Reference: 1230608 Published by Packt Publishing Ltd. 32 Lincoln Road Olton Birmingham, B27 6PA, UK. ISBN 978-1-847194-12-1 www.packtpub.com Cover Image by Vinayak Chittar (vinayak.chittar@gmail.com)
  • 8.
    Credits Author John Farrar Reviewers Rick Mason SeanCorfield Senior Acquisition Editor Douglas Paterson Development Editor Ved Prakash Jha Technical Editor Shilpa Dube Rasika Sathe Copy Editor Sumathi Sridhar Editorial Team Leader Mithil Kulkarni Project Manager Abhijeet Deobhakta Project Coordinator Lata Basantani Indexer Hemangini Bari Proofreader Chris Smith Production Coordinator Aparna Bhagat Cover Work Aparna Bhagat
  • 9.
    About the Author JohnFarrar started working with computer programming around 1977. He has had the opportunity to work on projects used by Apple, Blue Cross, Brunswick Recreation, Casio, GVSU, Johnson Controls, Sprint, and many others. This history covers over 30 years of knowledge and experience in the industry. He started doing web development over ten years ago. In the early days of the Web, ColdFusion stood out to him not just as a way to make web pages into web applications but as a maturing solid platform good for the developer, site owner, and end users. He started at version 4.5 and has been enjoying every version upgrade more and more. John owns a company called SOSensible. His company does work for large companies but has a special focus on also making sure technology is approachable beyond the enterprise. It has developed a number of Open Source solutions including COOP. COOP is a mix of "Custom Tags" and "CFCs" that provides structure while keeping development simpler. It demonstrates his love for the things that make ColdFusion/CFML a delightful language to build websites. COOP is a pet project of his that can allow upgrades of AJAX libraries and add in features as the libraries grow. He has spoken at national and regional conferences, online meetings, and area user group meetings. He is also an Adobe User Group manager. John knows that community is a viable and productive tool to build developers and the companies they serve. He has learned much from great resources in the community including bloggers, books, conferences, and resources to great in number to mention here. He blogs them at http://www.sosensible.com/index.cfm/blog/index/ and encourages others to join in and build the community with him. Contact: johnfarrar@sosensible.com Alternative Email: sosensible@gmail.com.
  • 10.
    Thanks to DouglasPaterson, and the many staff members of Packt Publishing for helping me through my first published book. The guides and interaction were a great experience that helped me in numerous ways. There were a couple of community editors who helped review technical content. These assistants were Sean Corfield and Rick Mason and many of the suggestions made by them have been added to this book and are on file towards any revisions in the future. The efforts of the various people who work on Open Source and share their work with the community at large should be appreciated. Several were kind enough to work with me if there were any questions in writing this book and it is truly appreciated. Also thanks to the love of my life, Jeanine, who enthusiastically motivated me to see the book through to completion.
  • 11.
    About the Reviewers SeanCorfield is the architect behind large-scale, high-availability websites for companies such as Macromedia, Toshiba, Oracle, Toyota, and Thomas Cook. He is a frequent speaker on software design within the ColdFusion community, at user groups and conferences across the world. Sean has championed and contributed to a number of ColdFusion frameworks and his passion for standards and software engineering led him to work on the C++ Standards Committee for eight years. He is currently Chief Systems Architect and Vice President of Engineering at Broadchoice, Inc. based in the Bay Area, California. Contact: sean@corfield.org Rick Mason has been programming for over 20 years and has been a ColdFusion developer since 1999. He started SeedChoices.com, an ASP sales force automation solution for the farm seed industry seven years ago. Mr. Mason is currently Senior Web Developer for SeeProgress.com. The Brighton, MI based firm lets consumers view progress of repairs online. They were honored in 2007 as one of the top 50 companies in the state to watch by the Edward Lowe foundation. He also manages the Mid-Michigan ColdFusion Users Group, www.coldfusion.org, and is an active member of the ColdFusion community. Contact: rmason@acd.net Alternative Email: Rick@SeedChoices.com I would like to thank my nieces, Danielle and Sarah Stone, for their continued inspiration.
  • 12.
    Table of Contents Preface1 Chapter 1: Web Pages—Static to Dynamic 7 Turning HTML into a Dynamic Web Page 7 Understanding and Using Simple Variables 11 Understanding Structures 16 Let Us Get Interactive 18 Setting Page Defaults 23 Introduction to Lists and Loops 27 Understanding Arrays 29 Conditional Processing with If 32 Conditional Processing with Switch 35 Summary 36 Chapter 2: Basic CFCs and Database Interaction 37 Our First CFC 38 Our First Object 38 Product (object) 38 Using an Object Constructor 42 Connecting to a Database 45 Returning Data from the CFC 47 Making Our Data Query Flexible 50 The Basic Data Object Concept 53 Object Method Access Control 56 Summary 57 Chapter 3: Power CFCs and Web Forms 59 The Practice of Protecting Access 60 Web Forms Introduction 61 Managing Our Product Data 64 Getting Data to Our Edit Page 65
  • 13.
    Table of Contents [ii ] Saving Our Data 68 Improving Page Flow 71 Adding a New Record 72 Let Us Look Under the Hood 74 Summary 76 Chapter 4: Application, Session, and Request Scope 77 Life Span 77 Introducing the Application.cfc Object 79 Application Variables 82 The Start Methods 85 Application Start Method 85 Session Start Method 86 Request Start Method 87 The End Methods 87 Request End Method 88 Session End Method 88 Application End Method 88 On Error Method 89 Scope Visibility 89 Practical Application 92 Mappings per Application 93 Custom Tag Paths per Application 93 Summary 94 Chapter 5: Introduction to Custom Tags 95 Different Forms of Code Reuse 95 CFCs 96 Custom Tags 96 CFInclude 96 Our First Custom Tag 97 Custom Header/Footer Tags 98 Nested Tags 101 CFInclude from Custom Tags 106 Templates versus Skins 109 Managing Custom Tags 110 CFModule Approach 110 Tag Library Approach 111 Summary 111 Chapter 6: Better Interfaces for JavaScript Libraries 113 Thickbox Library HTML Style 114 ColdFusion-Powered Thickbox 116
  • 14.
    Table of Contents [iii ] Where Am I? (via Google Maps) 121 ColdFusion JavaScript 127 Multiple State Form Items 128 Inside the Fancy Form Tag 130 Summary 132 Chapter 7: Authentication and Permissions 133 How ColdFusion Recognizes Users 133 Custom Authentication (Additional Power) 138 Authentication Data Model 139 How to Use Advanced Authentication 142 Extra Notes 146 Summary 146 Chapter 8: CF AJAX User Interface 147 HTML-Based Websites 147 Server-Side Languages 148 Browser-Side Applications 148 Flash 148 JavaScript 148 ColdFusion AJAX 149 Layout 149 <cfdiv /> 149 <cflayout /> 151 <cfpod /> 157 <cfwindow /> 158 Menus and Tool Tips 163 <cfmenu /> 163 <cftooltip /> 166 Styling Notes 168 Tips 168 Summary 169 Chapter 9: CF AJAX Forms 171 Forms 171 <cfgrid /> 172 Grid Paging 173 Grid Updates and Deletes 176 Linked Grids 179 <cfinput /> 181 Binding Page Elements 181 Binding Immediately upon Load 182 The Date Requestor 184
  • 15.
    Table of Contents [iv ] The Autosuggest Box 185 <cfselect /> 187 <cftextarea /> 190 <cftree /> 192 The Directory Tree 194 Summary 197 Chapter 10: CF AJAX Programming 199 Binding 199 On Page Binding 200 CFC Binding 200 JavaScript Binding 202 URL Binding 203 Bind with Event 204 Extra Binding Notes 205 Multiple Radio Buttons or Check Boxes and Multiple Select 206 Spry Binding 206 CFAJAXProxy 206 CFAJAX Proxy Binding 207 CFC Proxy Class Objects 208 Client Debugging 213 Firebug 213 Built-In Debugging 215 Logging Features 216 Customization 217 Automatically Wired AJAX Links 218 Execute JavaScript after Loading Content 219 Other Cool Commands 220 Post for CFAJAX Calls 221 Summary 221 Chapter 11: Working with PDF 223 Generating PDF Pages 223 Our First PDF Page Conversion 223 Splitting into Sections 224 Adding Headers and Footers and Variables 225 Adding Page Breaks and Variables 226 Adding Bookmarks 227 Saving PDF Documents 228 Printing from the Server 228 Working with PDF Forms 230 Populating PDF Forms with Data 230
  • 16.
    Table of Contents [ ] Reading Data from PDF Forms 233 Manipulating PDF Documents 234 Merging Documents 234 Deleting Pages 235 Encrypting PDF Documents 235 Generating Thumbnails 236 Adding Watermarks 237 Final Thoughts 238 Summary 239 Chapter 12: Building Search Abilities 241 Database Searching 241 Verity Search Solutions 241 Built-In Search Engine 242 Creating a Collection 242 Indexing a Collection 244 Searching a Collection 245 The Search Form 246 The Results Page 246 Search Techniques 248 PDF Linking to Searches 250 Suggestions 251 Integrating Third-Party Searching 252 Google Details 252 Custom Search Engines (Google) 253 On-The-Fly Search Engine 253 Simple Search 256 Search Types 257 Site Restricted 259 Local Search 260 Summary 261 Chapter 13: Working with Files, Email, and Images 263 Working with Files 263 Uploading Files 263 Local File Control 266 Write File 268 Read File 268 Rename File 269 Append File 270 Read File via Loop 270 Working with Email 270 Working with Images 274 Image Information 277 Summary 281
  • 17.
    Table of Contents [vi ] Chapter 14: Feeds, REST Services, and Web Services 283 Collaboration 283 Flickr 283 Feeds 283 RSS 284 CDF 288 JSON 289 SQL 292 Introduction to REST Services 292 SOAP Web Services 298 Summary 303 Chapter 15: Building Dynamic Reports 305 Traditional Web Page Reporting 305 Simple Report 305 Grouped Data 307 Drill-Down Reporting 309 Output Formats 311 PDF Output 312 Excel Output 313 CVS Output 315 XML Output 316 JSON Output 316 Using CFReport and Report Builder 317 Summary 325 Chapter 16: Dynamically Generated Web Presentations 327 Introduction to CFPresentation 327 Mixing in the Media 329 Caching the Contents 334 Dynamic Benefits 338 Scenario 1: Sales Force 338 Scenario 2: Client-Specific Presentations 339 Scenario 3: Live Audience Sensitive Content 339 Summary 340 Appendix A: Getting Your System Ready for Development 341 Tools 341 AJAX 344 Ant 345 Database Engines 345 Database Tools 347
  • 18.
    Table of Contents [vii ] Media Tools 347 Audio Software 348 Image Software 348 Video Software 349 Reporting 350 SVN 350 Unit Testing 350 Conclusions 351 Appendix B: Resources to Build Your Skills 353 Blogs 353 ColdFusion Conferences 354 Coding Frameworks 355 General ColdFusion Sites 357 Libraries and Tools 358 Aspect or IoC or DI 358 Content Handling/Generation 359 Database 359 JavaScript 361 Project Management 363 Script 363 Search 364 Site Integration APIs 364 Unit Testing or Debugging 370 XML Tools and Products 371 Other Notable Works 373 Index 375
  • 20.
    Preface Adobe ColdFusion isan application server, renowned for rapid development of dynamic websites, with a straightforward language (CFML), powerful methods for packaging and reusing your code, and AJAX support that will get developers deep into powerful web applications quickly. This book is the most intense guide to creating professional ColdFusion applications available. Packed with example code, and written in a friendly, easy-to-read style, this book is just want you need if you are serious about ColdFusion. This book will give you clear, concise and, of course, practical guidance to take you from the basics of ColdFusion 8 to the skills that will make you a ColdFusion developer to be reckoned with. ColdFusion expert John Farrar will teach you about the basics of ColdFusion programming, application architecture, and object reuse, before showing you a range of topics including AJAX library integration, RESTful Web Services, PDF creation and manipulation, and dynamically generated presentation files that will make you the toast of your ColdFusion developer town. This book digs deep with the basics, with real-world examples of the how and whys, to get more done faster with ColdFusion 8. This book also covers the new features of ColdFusion 8 Update 1. What This Book Covers Chapter 1 describes how to enhance basic HTML pages with the power and simplicity of ColdFusion. It also explains the difference between static HTML pages and dynamic ColdFusion pages.
  • 21.
    Preface [ ] Chapter2 describes how to create object classes and instantiate object instances. It also describes the object constructors. This chapter explains how to connect to a database through the internal methods of our objects. Chapter 3 helps us in understanding how to manage multiple products through common forms for listing, editing, and adding data. This chapter explains integrating and streamlining the workflow of web forms and CFC database processing. In Chapter 4, we will learn how to use the web server memory to create engaging and interactive web applications by using variable scopes. We will also learn how to share some information, and how to protect the rest of the information in a controlled manner. In Chapter 5, we will learn about the basics of custom tags. We will also learn how to integrate cfinclude for libraries of segments. This chapter also includes skinning a website by using custom tags, the use of nested tags, and so on. Chapter 6 includes wrapping of the ThickBox gallery functions into a custom tag for simple functional reuse and wrapping of a Google map library into our code with a custom tag for simplified interactive maps. This chapter helps us in understanding how to create a multi-state form list wrapped in a custom tag. In Chapter 7, we will see how to use the authentication that comes standard with CF. This chapter explains how to control the site content based on current user permissions. In Chapter 8, we will see how AJAX is different from HTML and regular server-oriented web pages. This chapter includes the comparison of HTML, server, and browser technology sites. It also explains about the ColdFusion widgets. In Chapter 9, we will see the benefit received from the combined power of tag-based encapsulation with AJAX functionality. Chapter 10 explains about binding, proxy connections, JSON features, Spry data integration, and debugging. In Chapter 11, we will have a look at the different ways in which we can reorganize pages of PDF documents into a new PDF file from one or more separate PDF source documents. Chapter 12 explains how to create Verity search collections, how to initialize the Verity indexes, how to interface with the indexes. This chapter also explains how to interface with PDF content for more control when calling documents.
  • 22.
    Preface [ ] Chapter13 discusses files, emails, and images. This chapter helps in understanding how some of the common ColdFusion features empower developers to shift the web pages to web applications in many ways. In Chapter 14, we will learn how to interact with other web servers and create features on our site that will allow others to interact with us. Chapter 15 gives a broad introduction to ColdFusion's way of generating dynamic reports. This chapter also gives a brief introduction to the ColdFusion Report Builder tool. Chapter 16 shows the unique presentation capabilities built into ColdFusion. It gives practical examples to help build custom presentations with dynamic content on demand. Appendix A covers some important details of setting up a development environment. It also includes some important tips for better productivity. Appendix B includes some links and resources that are aimed at giving us a good starting base of information. It also explains a group of libaries that prove to be very significant. What You Need for This Book For ColdFusion 8 Developer Tutorial, you will require the ColdFusion version 8. Updater 1. You will need an SQL server for creating the databases or phpMyAdmin site/SQL server will also do. Who This Book Is For This book is for web developers working with ColdFusion 8. If your goal is to get a good grounding in the basics of the language as quickly as possible and put a site together quickly, this book is ideal for you. If you want to learn more about professional programming of ColdFusion, this book is definitely for you. No prior knowledge of ColdFusion is expected, but basic knowledge of general web and software development skills is assumed.
  • 23.
    Preface [ ] Conventions Inthis book, you will find a number of styles of text that distinguish between different kinds of information. Here are some examples of these styles, and an explanation of their meaning. There are three styles for code. Code words in text are shown as follows: You will also observe that there is an attribute called access=public in many of the methods. A block of code will be set as follows: cfscript objProduct = createObject(component,product_1).init(); objProduct.set_name(name=Egg Plant); result = objProduct.get_name(); /cfscript !--- Content --- cfoutput #result# /cfoutput When we wish to draw your attention to a particular part of a code block, the relevant lines or items will be made bold: tr tdDescription:/td td textArea name=description id=idDescription/textArea /td /tr New terms and important words are introduced in a bold-type font. Words that you see on the screen, in menus or dialog boxes for example, appear in our text like this: We could have your site link from About Us to a pop-up window rather than a whole separate page. Important notes appear in a box like this. Tips and tricks appear like this.
  • 24.
    Preface [ ] ReaderFeedback Feedback from our readers is always welcome. Let us know what you think about this book, what you liked or may have disliked. Reader feedback is important for us to develop titles that you really get the most out of. To send us general feedback, simply drop an email to feedback@packtpub.com, making sure to mention the book title in the subject of your message. If there is a book that you need and would like to see us publish, please send us a note in the SUGGEST A TITLE form on www.packtpub.com or email suggest@packtpub.com. If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide on www.packtpub.com/authors. Customer Support Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase. Downloading the Example Code for the Book Visit http://www.packtpub.com/files/code/4121_Code.zip to directly downlad the example code. The downloadable files contain instructions on how to use them. Errata Although we have taken every care to ensure the accuracy of our contents, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in text or code—we would be grateful if you would report this to us. By doing this you can save other readers from frustration, and help to improve subsequent versions of this book. If you find any errata, report them by visiting http://www.packtpub. com/support, selecting your book, clicking on the let us know link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata added to the list of existing errata. The existing errata can be viewed by selecting your title from http://www.packtpub.com/support. Questions You can contact us at questions@packtpub.com if you are having a problem with some aspect of the book, and we will do our best to address it.
  • 26.
    Web Pages—Static to Dynamic Inthis chapter, you will learn how to enhance basic HTML pages with the power and simplicity of ColdFusion. This book demonstrates how to apply different techniques by building them into different real-world scenarios. In this chapter, we will apply what we learn about a prototype of a typical FAQ (Frequently Asked Questions) section of a website. We will cover the following skills in the process: Moving from HTML to dynamic web pages Simple and structured variables URL and CGI variable structures Setting default variables for pages Debugging and exception-handling techniques Working of lists and arrays in ColdFusion Repetition processes done with looping commands Conditional processing Turning HTML into a Dynamic Web Page Let us take a look at the differences between common HTML pages and the power of a server-side language. For now, we will leave the pleasant side of web pages. This is because we are going to focus our thinking on ColdFusion. If you need help in setting up your system for development, see Appendix A. • • • • • • • •
  • 27.
    Web Pages—Static toDynamic [ ] Copy the tutorial/chapter_1 directory to the cfb/chapter_1 directory inside your server root. From your browser, enter� http://localhost/cfb/chapter_ 1/1_1.htm in your address bar, and you will see a basic FAQ page. Open the view source option from the browser, and compare that with the code you will find when you open the file in an editor. You will find the same pages. Here, you will see that a normal server returns common HTML pages. When ColdFusion is added, we have an extra step to how the pages are managed by the server. As a result, we are able to create pages that are made dynamic from the server side of the equation. This concept is the same for all server-side languages. Now, let us get into a very basic introduction to ColdFusion. We will take one step at a time. Here is the code segment with common HTML. If you type the following code in an HTML page and load it into the browser, it will look the same as it does in the view source from the browser: !-- Example: 1_1.htm -- !-- HTML Comment -- div h3Question: What is a variable?/h3 pstrongAnswer:/strong/p p Variables are named storage containers inside programming languages. Just think of variables as any type of named container holding any type of stored content. You simply name the container and store the content. Later you retrieve the content by using the same name./p p12:53 PM/p /div
  • 28.
    Chapter 1 [ ] Now, we will look at a more dynamic version of the page by listing the required changes. You may be able to tell what is going on without any help, just by depending on your programming background. Copy the file 1_1.htm and save it as 1_2.cfm in the same directory. Go back to the browser, and look for the web page, http://localhost/cfb/chapter_1/1_2.cfm. This page looks the same, and the code is basically the same if you use the browser page source view. We are going to add the following two highlighted lines above the !-- HTML Comment --: !--- Processing --- !--- Content --- !-- HTML Comment -- You will notice that the two new lines have three dashes instead of two. This is because they are ColdFusion comments. If you go back to the browser and refresh the page, you will find something interesting when you view the source. The new comment lines, which you had added, are not shown on the page source since they are server-side ColdFusion comments. Remember to save the file before checking for the results. First we have to create variables in ColdFusion. Add a line between the processing and content comments, and create the following two variables inside the CFSet tags. These variables are containers to store content for later use. Currently, we will be using them as text containers, and they will be known as string variables. !--- Processing --- cfset myQuestion = cfset myAnswer = !--- Content ---
  • 29.
    Web Pages—Static toDynamic [ 10 ] Cut the actual question out of the content section and paste it inside the quotes of the string variable, myQuestion. Now, cut the answer text out of the content section and paste it inside the quotes of the string variable,� myAnswer. (The question and answer are the same as those specified in the previous example code.) Now, we need to put the content, which we have moved to variables, back into the page. ColdFusion was the first to standardize server-side code tags. These look very much like HTML tags, but they add power and simplicity. We need to wrap our entire content section with CFOutput. Add the� cfoutput opening tag right after the� --- Content --- ���������������������� tag, and then put the /cfoutput closing tag as the last line of the code page. We have to place the variables in the content section of the code with some special ColdFusion output markers. ColdFusion uses the pound symbols on both sides of the dynamic content for markers. So put #myQuestion# in the place where you cut out the content section for the myQuestion variable. Also, place� #myAnswer# where you cut out the content section for the myAnswer variable. Save the file, and then run the page. (Check the following sample code for any issues to make sure that you typed things correctly. Then refresh the page again.) We can output more variables. You can also replace the time with the function in the following code, at the end of the ColdFusion code sample. You can refresh the page over and over, and see that the time is being dynamically generated on the server: !--- Example: 1_2.cfm --- !--- Proccessing --- cfset myQuestion = What is a variable? cfset myAnswer = Variables are named storage containers inside programming languages. Just think of variables as any type of named container holding any type of stored content. You simply name the container and store the content. Later you retrieve the content by using the same name. !--- Content --- cfoutput div h3Question: #myQuestion#/h3 pstrongAnswer:/strong/p p#myAnswer# /p p#timeFormat(now())#/p /div /cfoutput
  • 30.
    Chapter 1 [ 11] The now() function in ColdFusion returns the current date or time. The timeFormat() function converts the output to display text with the time of its contents. If we update the screen, the current time will be displayed on each refresh. Your first dynamic web page is created. If you do not know much, there is no need to worry. We will create web pages after this exercise. If you are new to this technology, then work through the examples and complete the chapter. Take a break, and then come back after going through the entire chapter, and repeat the exercises. You will be surprised by what you have learned. We will be removing the HTML standard wrappers from most of the examples in the book. Browsers do not need the markers to present the content. In your live site code, the markers should be included. Understanding and Using Simple Variables In this section, we will have a look at a couple of variable types with the help of which you will be getting an idea of how ColdFusion works with variables. We are going to look at the different types of simple variables.
  • 31.
    Web Pages—Static toDynamic [ 12 ] There are four types of simple variables: string, numeric, Boolean, and date or time variables. Although a variable can have any name, there are a few basic guidelines for naming variables. They are as follows: A variable name must begin with a letter, which can be followed by any number of letters, numbers, and underscore characters. A variable name cannot contain spaces. Variable names are not case sensitive in ColdFusion. (myVariable is the same in ColdFusion as Myvariable.) We will be covering two number classes, in this lesson. First, we will take a look at the integers. These are numbers with no decimal value. ColdFusion supports integers between - 2,147,483,648 and 2,147,483,647. It will also work with numbers outside this range, but the precision will not be exact. In the first example given below, we will modify the code that we have been using to keep one of the string variables and add a numeric variable called myAge. The following two code examples are identical, so it is fine to do it either way. Proper indentation is key to either tag or the script-based code. (Run the code examples.) !--- Processing --- cfset myQuestion = This is my question. cfset myAge = 27 !--- Content --- cfoutput myQuestion is (#myQuestion#)br / myAge is (#myAge#)br / /cfoutput !--- Processing --- cfscript myQuestion = This is my question.; myAge = 27; /cfscript !--- Content --- cfoutput myQuestion is (#myQuestion#)br / myAge is (#myAge#)br / /cfoutput • • •
  • 32.
    Chapter 1 [ 13] You will notice that strings are declared with quotation marks. These can be either single or double quotation marks. Numbers do not use quotation marks. This would be the same in a variable declaration. In the preceding examples, it is in the form of an expression. Expressions are what we call code when we combine strings, or do math or some Boolean comparisons. Here, we will look at our first expression example by changing both the string and the numeric variables in our code. ColdFusion 8 added the += operator to the platform. This is a widely used notation to add the righthand value to the original value. Run the following example: !--- Example: 1_3.cfm --- !--- Processing --- cfscript myQuestion = This is my question.; myAge = 27; myQuestion = myQuestion Is this a string?; myAge += 1; /cfscript !--- Content --- cfoutput myQuestion is (#myQuestion#)br / myAge is (#myAge#)br / /cfoutput There is no requirement to write things in CFScript like the ones you will see in the book. Currently, JavaScript, AIR/Flash/Flex ActionScript, .Net, PHP, and JAVA use scripted code. These are the most common forms of coding.
  • 33.
    Web Pages—Static toDynamic [ 14 ] Now, we will look at decimal-based numbers. We will modify the code to show some more things that you can do with numbers and to remove the string functions. !--- Example: 1_4.cfm --- !--- Processing --- cfscript myAge = 27; halfAge = myAge/2; /cfscript !--- Content --- cfoutput myAge is (#myAge#)br / halfAge is (#halfAge#)br / halfAge rounded is (#round(halfAge)#)br / 4.2 rounded is (#round(4.2)#)br / 4.2 ceiling is (#ceiling(4.2)#)br / /cfoutput If you would like to have more information about the built-in functions, then you can download the manuals in Appendix A and go through the PDF documents. You will find that there are abundant built-in functions for application processing. We have looked at creating a variable by using the value of another variable and by changing the values of variables. You will find everything from modulo functions to geometry functions for standard mathematical calculations. You will also find a rich number of string functions that can help you process your pages. The following piece of code will help you find the additional types of things that you can do with strings: !--- Example: 1_5.cfm --- !--- Processing --- cfscript myQuestion = This is my question.; myQuestion = myQuestion Is THIS a string?; location = find(this,myQuestion);
  • 34.
    Chapter 1 [ 15] /cfscript !--- Content --- cfoutput myQuestion is (#myQuestion#)br / Location of this is (#location#) characters from the start of the string.br / /cfoutput You might be curious to know why the value of the find returned zero rather than the actual position. You will notice that we changed the word this to THIS. Computers see upper case letters differently from lower case letters. So THIS proved the point that strings are case sensitive. Let us see how we can find an alternative way with a ColdFusion's built-in function: !--- Example: 1_6.cfm --- !--- Processing --- cfscript myQuestion = This is my question.; myQuestion = myQuestion Is THIS a string?; location = findNoCase(this,myQuestion); location2 = findNoCase(this,myQuestion,location+1); /cfscript !--- Content --- cfoutput myQuestion is (#myQuestion#)br / Location of this is (#location#) characters from the start of the string.br / The second this is located at position (#location2#).br / /cfoutput
  • 35.
    Web Pages—Static toDynamic [ 16 ] Here, we did a couple of things. First, we made our string search case insensitive. Then we added a second search to see if there were any more occurrences of the item being searched for in the string variable. We added +1 to the location in order to make sure that we skipped the first location in our search. It still returns the location based on the start of the string irrespective of an in-depth search. The following code shows the structure of the function that will help you understand the working of the function documentation: FindNoCase(substring, string, [start]) The arguments of the functions are required unless they are wrapped in [ ]. This function searches for a substring inside string, optionally starting at start number of characters into the string. Understanding Structures Structures are one of the most powerful variables that we will be looking at in this book. An example is described that illustrates the working of the structure. Structures are like files and folders on a computer file system. Folders can be empty or they can contain multiple files or nested folders. Files may contain different types of content. Yet, you can never call a folder directly and retrieve the actual file content from a folder. Structures in ColdFusion work along the same concepts���������������������� . Your structures can be empty or they may contain both additional nested structures and variables holding data. Let us look at our first built-in structure type called CGI. We will take a look at the most commonly used debugging tool for many developers. CGI is a collection of variables that gives details about things ranging from the current request, the browser of the requesting user, to information about the current running server. It does not tell us everything, but it does provide us with good information so that we may visit over and over again. All the structures start with a base structure element. The CGI structure starts with cgi followed by a dot (.) with the structure variable name: cgi.structure_item_name
  • 36.
    Chapter 1 [ 17] Let us look at an easy way to see what is available. If you do this yourself, you can scroll through and see how much information is offered. Here is the simple code. You will also note that the pound symbols surround the variable name. This is required for functions to work correctly. It may seem odd at first, but you will be able to grasp it quickly even if you do not get it at the first glance: !--- Example: 1_7.cfm --- !--- Processing --- !--- Content --- cfdump var=#cgi# The cfdump tag in ColdFusion takes any complex data type, and creates a grid or nested grid if there is a nested structure to display the contents of the variable. Dump allows us to see the state of a variable structure at a fixed point in the processing cycle of our web page. There are options for not expanding, and for giving a label to the dump for occasions when we may put more than one dump on a page during the programming cycle. We will not want to use this type of function on final production code because users might think that the system has crashed. When it comes to programmers, this is one of the greatest, and it has been one of the features of ColdFusion widely used by developers for many years. We will look at the end of the page where we can see the server port, if the port was secure, and that there were many other details with this dump.
  • 37.
    Web Pages—Static toDynamic [ 18 ] You will see everything from the cookie variables to the remote address of the requesting user. If you were to access these directly in the code, you would have to do it as follows. You will notice that the structure 'cgi', contains a good number of variables. In this case, there are no nested structures but only variables. This makes for a better introduction to the structures: !--- Example: 1_8.cfm --- !--- Processing --- cfscript requestedDomain = cgi.server_name; isSecure = cgi.server_port_secure; /cfscript !--- Content --- cfoutput The requested domain was #requestedDomain#.br / Was the current request secure (0 = No/1 = Yes) ? #isSecure# br / /cfoutput Let Us Get Interactive We are going to get into a round trip interaction with web pages. This is the reason why web programming beginners will agree as to why these web pages are known as Dynamic Web Pages. We will be learning a new structure called URL, and see one way to pass information from the user back to the server. We will start by calling the same page via the URL in order to understand this functionality. We will run the same code twice. For the first time we will not pass any URL variables.
  • 38.
    Chapter 1 [ 19] As seen on the screen, our first example returned an empty structure. For the second example run, you will see that we passed a URL variable called NAME with a value, John. You can actually pass in many URL variables at the same time. This structure works the same way as the CGI structure. We need to add name=John at the end of the URL to get the structure. Here is the URL: http://localhost/cfb/code/chapter_1/1_9.cfm?name=John It does not contain any nested structure, so you could output the variable for name in content as follows: cfoutput My name is #url.name#. /cfoutput Many of the failed web pages come when we start getting interactive. In addition to having a look at the use of URL variables, we will take a brief look at how to catch missing variables with the use of the URL variables. This is known as exception handling in programming. Universally, the try catch method is used. This will be visible in script usage, and in tag usage. This will also be an opportunity for you to understand the concept of error or exception pages as you build ColdFusion applications and you find that things are not working as planned.
  • 39.
    Web Pages—Static toDynamic [ 20 ] !--- Example: 1_10.cfm --- !--- Processing --- !--- Content --- cfoutput My name is #url.name#.br / /cfoutput We will start by running the page. In the URL type in the address followed by ?name=John. Type the URL precisely with the question mark. Here is the URL: http://localhost/cfb/code/chapter_1/1_10.cfm?name=John Now, we will intentionally generate our first error. Remove the question mark from the end of the browser address box and the rest that follows it. Refresh the page.
  • 40.
    Chapter 1 [ 21] Many times, you will see the detailed information on the screen, as shown in the earlier figure, when an error occurs. Not only did it tell us about the error but it also showed us the line of code where the error occurred. Do not count on this to happen all the time. By learning the use of the try catch block, the number of these issues will be reduced. In our next version of code, you will see how the try catch block can be used on the page to manage and help fix these errors: !--- Example: 1_11.cfm --- !--- Processing --- !--- Content --- cftry cfoutput My name is #url.name#.br / /cfoutput cfcatch cfdump var=#cfcatch# /cfcatch /cftry Here, the information is presented in a different manner but it gets you to the same end. The exception is placed on the page using a cfdump tag. Most often, you will find that this is the most useful approach to debugging. You can also email the contents of the catch structure to an administrator. You may also note that the StackTrace and objectType structure elements have been minimized. You toggle elements in CFDump by clicking on the element text. This will hide all the nested information until you desire to see it again.
  • 41.
    Web Pages—Static toDynamic [ 22 ] You might wonder why we included exception or error handling with CFDump. It is because the results of the catch are stored in a variable called cfcatch that contains a pleasant structure collection. Inside the structure, you will find a nested structure called TagContext. Let us modify our code so that just one subset of this structure is displayed on the screen. Change the cfdump to the following in your code: cfdump var=#cfcatch.TagContext# The structure allows us to drill down the pieces of information that we are interested in without pulling the rest of the details along with them. We have not covered arrays but you can drill down to the page where the problem occurred. We will learn how arrays work in ColdFusion. But now, let us change the line of code once again, and try: cfdump var=#cfcatch.TagContext[1].template# You will notice that the wrapper for our CFDump has disappeared. It has disappeared because we are now outputting a simple variable. If there is no structure or complex variable, then we get a simple variable where the CFDump is located on the page. In this case, as the code error occurred at the end of the line, it will start right from there, and this explains why it is on the same line as the web page content in the browser.
  • 42.
    Chapter 1 [ 23] Setting Page Defaults The information that you will obtain from here can be applied to more than page defaults. This is the most common place where you should use it. We will make a minor change in the code while creating a new page. We will use the� cfparam tag to set the default values in the following code: !--- Example: 1_12.cfm --- !--- Processing --- cfparam name=url.name default=( unknown user ) !--- Content --- cftry cfoutput My name is #url.name#.br / /cfoutput cfcatch cfdump var=#cfcatch# /cfcatch /cftry Now, we have learned how to catch and handle exceptions. We have also learned how to solve such types of error in ColdFusion. We created a default value for this structure variable to prevent an error condition and handle it as a predictable exception. If we add the name back to the URL, it will still work as expected.
  • 43.
    Web Pages—Static toDynamic [ 24 ] We have one more thing that can be done to understand the URL structure. We need to add some standard browser links on the page, and then click on them to see what happens. We will be creating two styles of links. The first link will be a static link. This link will point back to our dynamic page to show one form of interaction through URL variables: !--- Example: 1_13.cfm --- !--- Processing --- cfparam name=url.name default=( unknown user ) !--- Content --- cftry cfoutput My name is #url.name#.br / a href=?name=TedShow this page with Ted for the name./abr / a href=?name=FredShow this page with Fred for the name./a br / /cfoutput cfcatch cfdump var=#cfcatch# /cfcatch /cftry Click on either of the links on the screen, and you will see that the variable stored in the link is passed through the next time it loads from the server to the page. You will also note that the address bar will display the variables passed in when the URL requests to reload the pages. As displayed on the screen, we will click on� Fred to try it.
  • 44.
    Chapter 1 [ 25] It will be clear that URL variables can come from more than one location. We have seen their existence in the address bar, and in web page links. Our final use of URL variables will involve some processing that is actually based on the changes to the links that we click. Enter the following code: !--- Example: 1_14.cfm --- !--- Processing --- cfparam name=url.counter default=10 cfparam name=url.calculate default=0 cfset url.counter += url.calculate !--- Content --- cfoutput I have #url.counter# cars.br / a href=?calculate=1counter=#url.counter#Add One./abr / a href=?calculate=-1counter=#url.counter#Subtract One./abr / /cfoutput You can click on add and subtract as many times as you like to know if the page has become very interactive. The counter is passed back with the counter change based on the link that we click for the server from the web page. We had specified earlier that to use the variables to create the content, we must wrap them inside a� CFOutput tag pair, and surround the variables with pound symbols.
  • 45.
    Web Pages—Static toDynamic [ 26 ] This will be our last version of the script. It will be a bit more interesting than the other scripts. We are going to create some custom structure, and detect how to interact with that structure using what we have learned: !--- Example: 1_15.cfm --- !--- Processing --- cfparam name=url.speed default=10 cfparam name=url.acceleration default=0 cfscript myCar = structNew(); myCar.color = blue; myCar.speed = url.speed + url.acceleration; /cfscript !--- Content --- cfoutput a href=?acceleration=-1speed=#myCar.speed#Slower/anbsp; a href=?speed=#myCar.speed#Cruise/anbsp; a href=?acceleration=1speed=#myCar.speed#Faster/abr / cfdump var=#myCar# label=My Car /cfoutput We have learned that creating a new structure is done by assigning a value to the variable using the function structNew(). You can nest structures inside the structures in addition to actual variable storage containers. It is the first step towards packaging your data inside the application. As applications grow, you will not want to do everything with simple variables setting at the root level of your variable structure. That would be impossible to maintain. Another note is that we have persisted the values of the speed of the car by passing through the URL variables. We will learn many interesting ways of making our values exist from one page call to the next. We have learned how to use the structure, and gained an understanding of the URL variables.
  • 46.
    Chapter 1 [ 27] Introduction to Lists and Loops Lists are stored inside string variables. You can also have a list variable stored inside a structure. Lists have a separator, which is commonly known as a� delimiter, to divide the items, so the server can evaluate them. We are going to return to our FAQ application concept and build on what we have learned. Let us look at the code for lists. !--- Example: 1_16.cfm --- !--- Processing --- cfparam name=url.speed default=10 cfparam name=url.acceleration default=0 cfscript questions = What is the speed limit?,What is a car?,How much is gas?; /cfscript !--- Content --- cfoutput The second question is:br /nbsp;nbsp;nbsp; #listGetAt(questions,2)# /cfoutput You can see that the list has three items in it. We have the content request the second item for display. The� listGetAt() function is one of the simple powerful functions that make ColdFusion easy to program. You will find a number of astonishing list functions built into the language. We will combine lists and loops so you can see how things work together. !--- Example: 1_17.cfm --- !--- Processing --- cfparam name=url.question default=What is the speed limit? cfscript questions = What is the speed limit?,What is a car?,How much is gas?;
  • 47.
    Web Pages—Static toDynamic [ 28 ] answers = 55,Depends who you ask!,more than before; myQuestion = listContains(questions,url.question);listContains(questi ons,url.question); /cfscript !--- Content --- cfoutput strong#listGetAt(questions,myQuestion)#/strongbr /Answer:nbsp; #listGetAt(answers,myQuestion)#br /br / /cfoutput All Questionshr / cfloop list=#questions# index=iQuestionlist=#questions# index=iQuestion cfoutput strongQ/strong: a href=?question=#iQuestion##iQuestion#/ abr / /cfoutput /cfloop We made two lists this time, one list for questions known as questions, and another for answers known as answers. When you build pairs of lists, check twice that they have the same number of items to prevent errors. This will keep us away from the debugging phase of development. If you look at where we assigned the numeric value of� myQuestion, you will see that we are able to match the question asked in the list. If there is an exact match, then the number of that item in the list is returned. You will also observe that in the CFLoop list, the index variable contains the actual item stored in that position in the list.
  • 48.
    Chapter 1 [ 29] Click on different questions, and see how things work. You will be able to see the variables being passed in the address bar. The listContains() function finds the accurate matches in a list. If you want to find the first item in a list with a partial match, then use ListFind(). Both of them have a NoCase version available. We will continue to provide more information on loops as we get into arrays in the next section. There are several types of loops, and these are among the most preferred commands with ColdFusion developers. Now, you have started to learn more about ColdFusion. Understand the finer points by applying your knowledge. Understanding Arrays An array is an interesting variable construct. It is a collection of commonly named variables with an index set. We will take the last code example and transfer it to arrays. Here we will change the back end, but the front end will run in exactly the same way, from a user's point of view. You will be able to see that we are now passing a variable from page to page in the following code rather than the whole questions as we did earlier. !--- Example: 1_18.cfm --- !--- Processing --- cfparam name=url.question default=1 cfscript question = arrayNew(1); question[1] = What is the speed limit?; question[2] = What is a car?; question[3] = How much is gas?; answer = arrayNew(1); answer[1] = 55; answer[2] = Depends who you ask!; answer[3] = more than before; /cfscript !--- Content --- cfoutput strong#question[url.question]#/strongbr /Answer:nbsp; #answer[url.question]#br /br / /cfoutput
  • 49.
    Web Pages—Static toDynamic [ 30 ] All Questionshr / cfloop from=1 to=#arrayLen(question)# index=iQuestion cfoutput strongQ/strong: a href=?question=#iQuestion##question[iQuest ion]#/abr / /cfoutput /cfloop We now have two array variable constructs. Before you start assigning variables to an array, you need to declare the variable as an array type. Arrays can be multi- dimensional. We will focus on a single-dimensional array. If you forget to pass the number of dimensions when you declare an array, you will get an error when the code runs. So, do remember to declare the number of dimensions. The maximum number of dimensions in ColdFusion is three. A large multi-dimensional array can consume huge amounts of computer memory. You will find a huge collection of array functions built into ColdFusion. You can use arrayDeleteAt() to remove an item in the middle of an array. There is also an arrayInsertAt() that does the reverse. The following three things are to be observed while using arrays: Items are not to be removed in the middle of an array list without using the built-in functions. This could result in a missing element and an error can occur when looping through the array collection. An item is not to be counted while it is in the indexed position. It may seem odd that we call the position of an index and think that the item can move. This is different because arrays are dynamic. The number of items in an array can change. The best way to do that is to use the function arrayLen(), as we did in the example code to obtain the current length of an array. Now we will rewrite and run the same code as a multi-dimensional array. This is also known as an array of structures. Each dimension of the array has a structure. This allows for some unique layout of data within your application memory. We will add a CFDump at the end of the code, and �������������������������������������� view ��������������������������������� the structure created as follows: !--- Example: 1_19.cfm --- !--- Processing --- cfparam name=url.faq default=1 cfscript faq = arrayNew(1); faq[1] = structNew(); • • •
  • 50.
    Chapter 1 [ 31] faq[1].question = What is the speed limit?; faq[1].answer = 55; faq[2] = structNew(); faq[2].question = What is a car?; faq[2].answer = Depends who you ask!; faq[3] = structNew(); faq[3].question = How much is gas?; faq[3].answer = more than before; /cfscript !--- Content --- cfoutput strong#faq[url.faq].question#/strongbr /Answer:nbsp; #faq[url. faq].answer#br /br / /cfoutput All Questionshr / cfloop from=1 to=#arrayLen(faq)# index=iFAQ cfoutput strongQ/strong: a href=?faq=#iFAQ##faq[iFAQ].question#/abr / /cfoutput /cfloop cfdump var=#faq#
  • 51.
    Web Pages—Static toDynamic [ 32 ] We have gone through what you can do with structures, arrays, and loops. ColdFusion ���������������������������������������������������������������������� experts find creative uses for them. They are quite simple to use and very flexible to implement. Conditional Processing with If Now, we have reached the last section of our quick introduction to ColdFusion. We would be remiss if we were to forget conditional processing. There are two tags that make the bulk of conditional processing in ColdFusion. The first tag is cfIf. If you are familiar with any other programming language, you will find this function as you expect. While coding with tags, the language should be able to differentiate between tag braces, and greater than and lesser than logic. In ColdFusion, this is done by replacing the greater than symbol with GT and the lesser than symbol with� LT. We use GTE for greater than or equal to, and LTE for lesser than or equal to. If something is equal, we can either use IS or EQ. Now, let us look at something related to the code. What can we do to make sure that someone does not play tricks with the URL, and make our page fail by changing the URL variables? Let us put in some conditional processing to perform business logic in the processing section: !--- Example: 1_20.cfm --- !--- Processing --- cfparam name=url.faq default=1 cfscript faq = arrayNew(1); faq[1] = structNew(); faq[1].question = What is the speed limit?; faq[1].answer = 55; faq[2] = structNew(); faq[2].question = What is a car?; faq[2].answer = Depends who you ask!; faq[3] = structNew(); faq[3].question = How much is gas?; faq[3].answer = more than before; /cfscript cfif NOT isNumeric(url.faq) cfset url.faq = 1 cfelse cfset url.faq = round(url.faq) cfif url.faq LT 1 cfset url.faq = 1 cfelseif url.faq GT arrayLen(faq)
  • 52.
    Chapter 1 [ 33] cfset url.faq = arrayLen(faq) /cfif /cfif !--- Content --- cfoutput strong#faq[url.faq].question#/strongbr /Answer:nbsp; #faq[url. faq].answer#br /br / /cfoutput All Questionshr / cfloop from=1 to=#arrayLen(faq)# index=iFAQ cfoutput strongQ/strong: a href=?faq=#iFAQ##faq[iFAQ].question# /abr / /cfoutput /cfloop We will skip the screenshot because there is no change as to how the user sees the page. The only difference is in the processing logic needed to prevent someone from messing with the stability of the page. This will lay the foundation for protecting things such as commerce pages. Earlier, we forgot about the Boolean variable type. The conditional statements inside the if statements evaluate to either true or false. These are the Boolean values. You will also find that you can use either a zero, or a non-zero number to represent a Boolean logical evaluation. Therefore, any expression that evaluates either to zero or false has the same results. The other non-zero numbers and values such as true, yes, and no are valid Boolean conditions. You can just take the same code and assign it to a variable. Then you could use the variable inside the if statement instead of evaluating the logic inside the statement. Normally, place it inside the� cfIf statement, which is more meaningful. cfset myBoolean = NOT isNumeric(url.faq) We examine to make sure that the variable is a number. You are advised to change the value in the address bar to text in order to prevent page breaks. You will find that it selects the first item because the input in the URL variable is invalid��������������� . This is done by using the logical condition NOT. The NOT condition takes the result of the test and reverses it. You will notice that if this is not the condition used, then an alternative set of code is processed: cfif NOT isNumeric(url.faq) We will attempt to break it by entering in a negative number, since there are no items at that location in the array index, which would have led to page break. We have prevented it with our conditional logic by resetting the value when any basic type of hacking occurs.
  • 53.
    Web Pages—Static toDynamic [ 34 ] Let us take another look at the code with all the processing logic inside the CFScript. The best part of the platform is that it is flexible; it can be done both ways: !--- Example: 1_21.cfm --- !--- Processing --- cfparam name=url.faq default=1 cfscript faq = arrayNew(1); faq[1] = structNew(); faq[1].question = What is the speed limit?; faq[1].answer = 55; faq[2] = structNew(); faq[2].question = What is a car?; faq[2].answer = Depends who you ask!; faq[3] = structNew(); faq[3].question = How much is gas?; faq[3].answer = more than before; if(! isNumeric(url.faq)) { url.faq = 1; } else { url.faq = round(url.faq); if(url.faq 1) { url.faq = 1; } else if(url.faq arrayLen(faq)) { url.faq = arrayLen(faq); } } /cfscript We only show the top half of the code here, because the content section of the code is identical to the previous example. You may notice that you can use some more traditional script-style logic symbols while coding in script. Both these should help in evaluating between syntax for the script and the syntax for the tag-based logic.
  • 54.
    Chapter 1 [ 35] Conditional Processing with Switch You can achieve contextual selection of code segments with the cfIf tag, but the cfSwitch tag ������������� has a unique style that will become a conditional processing favorite in certain scenarios. In this section, we will restructure the FAQ example using the switch statement logic. This is the best use of a switch statement, but it will help you understand how the logic works. You will not see any difference when you look at the browser from the user side. !--- Example: 1_22.cfm --- !--- Processing --- cfparam name=url.faq default= cfscript faq = arrayNew(1); faq[1] = structNew(); faq[1].question = What is the speed limit?; faq[1].answer = 55; faq[1].id = ‘a’; faq[2] = structNew(); faq[2].question = What is a car?; faq[2].answer = Depends who you ask!; faq[2].id = ‘b’; faq[3] = structNew(); faq[3].question = How much is gas?; faq[3].answer = more than before; faq[3].id = ‘c’; /cfscript cfswitch expression=#url.faq# cfcase value=b cfset question = faq[2].question cfset answer = faq[2].answer /cfcase cfcase value=c cfset question = faq[3].question cfset answer = faq[3].answer /cfcase cfdefaultcase cfset question = faq[1].question cfset answer = faq[1].answer /cfdefaultcase /cfswitch !--- Content --- cfoutput strong#question#/strongbr /Answer:nbsp; #answer#br /br /
  • 55.
    Other documents randomlyhave different content
  • 56.
    ENTERTAINING A CHIPMUNK CALLER Oncefive callers came, each stringing in behind another. Just as the fifth came in the door, there was a dispute among the others and one started to retreat. Evidently he did not want to go, for he retreated away from the open door. As number two started in pursuit of him, number three gave chase to number two. After them started number four, and the fifth one after all the others. The first one, being closely pressed and not wanting to leave the room, ran round the centre table, and in an instant all five were racing single file round the table. After the first round they became excited and each one went his best. The circle they were following was not large, and the floor was smooth. Presently the rear legs of one skidded comically, then the fore feet of another; and now and then one lost his footing and rolled entirely over, then arose, looking surprised and
  • 57.
    foolish, but witha leap entered the circle and was again at full speed. I enjoy having them about, and spend many a happy hour watching them or playing with them. They often make a picnic- ground of my porch, and now and then one lies down to rest upon one of the log seats, where, outstretched, with head up and one fore paw extended leisurely upon the log, he looks like a young lion. Often they climb up and scamper over the roof of my cabin; but most of their time on the roof is spent in dressing their fur or enjoying long, warm sun baths. Frequently they mount the roof early in the morning, even before sunrise. I am sometimes awakened at early dawn by a chipmunk mob that is having a lively time upon the roof. In many things they are persistent. Once I closed the hole that one had made in a place where I did not want it. I filled the hole full of earth. Inside of two hours it was reopened. Then I pounded it full of gravel, but this was dug out. I drove a stake into the hole. A new hole was promptly made alongside the stake. I poured this full of water. Presently out came a wet and angry chipmunk. This daily drowning out by water was continued for more than a week before the chipmunk gave it up and opened a hole about thirty feet distant. For eight years I kept track of a chipmunk by my cabin. She lived in a long, crooked underground hole, or tunnel, which must have had a total length of nearly one hundred feet. It extended in a semicircle and could be entered at three or four places through holes that opened upon the surface. Each of these entrance holes was partly concealed in a clump of grass by a cluster of plants or a shrub. I have many times examined the underground works of the chipmunk. Some of these examinations were made by digging, and others I traced as they were exposed in the making of large irrigation ditches. The earth which is dug from these tunnels is ejected from one or more holes, which are closed when the tunnel is
  • 58.
    completed. Around theentrance holes there is nothing to indicate or to publish their presence; and often they are well concealed. These tunnels are from forty to one hundred feet long, run from two to four feet beneath the surface, and have two or more entrances. Here and there is a niche or pocket in the side of the tunnel. These niches are from a few inches to a foot in diameter and in height. In one or more of these the chipmunk sleeps, and in others is stored his winter food-supply. He uses one of these pockets for a time as a sleeping-place, then changes to another. This change may enable the chipmunk to hold parasites in check. The fact that he has a number of sleeping-places and also that in summer he frequently changes his bedding, indicates that these efforts in sanitation are essential for avoiding parasites and disease. Commonly the bedding is grass, straw, and leaves; but in my yard the chipmunks eagerly seize upon a piece of paper or a handkerchief. I am compelled to keep my eyes open whenever they come into the cabin, for they do not hesitate to seize upon unanswered letters or incomplete manuscripts. In carrying off paper the chipmunk commonly tears off a huge piece, crumples it into a wad, and, with this sticking from his mouth, hurries away to his bedchamber. It is not uncommon to see half a dozen at once in the yard, each going his own way with his clean bed-linen. Chipmunks take frequent dust and sun baths, but I have never seen one bathe in water. They appear, however, to drink water freely. One will sip water several times daily. In the mountains near me the chipmunks spend from four to seven months of each year underground. I am at an altitude of nine thousand feet. Although during the winter they indulge in long periods of what may be called hibernating sleep, they are awake a part of the time and commonly lay in abundant stores for winter. In the underground granaries of one I once found about a peck and a half of weed seeds. Even during the summer the chipmunk occasionally does not come forth for a day or two. On some of these occasions I have found that they were in a heavy sleep in their beds.
  • 59.
    These in myyard are fed so freely upon peanuts that they have come to depend upon them for winter supplies. They prefer raw to roasted peanuts. The chipmunk near my cabin sometimes becomes a little particular and will occasionally reject peanuts that are handed to her with the shell on. Commonly, however, she grabs the nut with both fore paws, then, standing erect, rapidly bites away the shell until the nut is reached. This she usually forces into her cheek pocket with both hands. Her cheek pouches hold from twelve to twenty of these. As soon as these are filled she hurries away to deposit her stores in her underground granary. One day she managed to store twenty-two, and her cheek pouches stood out abnormally! With this swelled and uncouth head she hurried away to deposit the nuts in her storehouse, but when she reached the hole her cheeks were so distended that she was unable to enter. After trying again and again she began to enlarge the hole. This she presently gave up. Then she rejected about one third of the nuts, entered, and stored the remainder. In a few minutes she was back for more. One day she made eleven round trips in fifty-seven minutes. Early one autumn morning a coyote, in attempting to reach her, dug into her granary and scattered the nuts about. After sending him off I gathered up three quarts of shelled nuts and left about as many more scattered through the earth! Over these the jays and magpies squabbled all day. One day a lady who was unsympathetic with chipmunks was startled by one of the youngsters, who scrambled up her clothes and perched upon her head. Greatly excited, she gave wild screams. The young chipmunk was in turn frightened, and fled in haste. He took consolation with his mother several yards away. She, standing erect, received him literally with open arms. He stood erect with one arm upon her shoulder, while she held one arm around him. They thus stood for some seconds, he screeching a frightened cry, while she, with a subdued muttering, endeavored to quiet him. Once, my old chipmunk, seeing me across the yard, came bounding to me. Forgetting, in her haste, to be vigilant, she ran into a family of weasels, two old and five young ones, who were crossing
  • 60.
    the yard. Instantly,and with lion-like ferocity, the largest weasel leaped and seized the chipmunk by the throat. With a fiendish jerk of his head the weasel landed the chipmunk across his shoulders and, still holding it by the throat, he forced his way, half swimming, half floundering, through a swift brook which crossed the yard. His entire family followed him. Most savagely did he resent my interference when I compelled him to drop the dead chipmunk. The wise coyote has a peculiar habit each autumn of feasting upon chipmunks. Commonly the chipmunks retire for the winter before the earth is frozen, or before it is frozen deeply. Apparently they at once sink into a hibernating sleep. Each autumn, shortly after the chipmunks retire, the coyotes raid all localities in my neighborhood in which digging is good. Scores of chipmunks are dug out and devoured. Within a quarter of a mile of my cabin one October night forty-two holes were dug. Another night fifty-four holes were dug near by. In a number of these a few scattered drops of blood showed that the coyote had made a capture. In one week within a few miles of my cabin I found several hundred freshly dug holes. Many holes were dug directly down to the granary where the stores were scattered about; and others descended upon the pocket in which the chipmunk was asleep. In a few places the digging followed along the tunnel for several yards, and in others the coyote dug down into the earth and then tunneled along the chipmunk's tunnel for several feet before reaching the little sleeper. So far as I know, each old chipmunk lives by itself. It is, I think, rare for one to enter the underground works of another. Each appears to have a small local range upon the surface, but this range is occasionally invaded by a neighboring chipmunk. This invasion is always resented, and often the invader is angrily ejected by the local claimant of the territory. In my locality the young are born during the first week in June. The five years that I kept track of the mother chipmunk near my cabin, she usually brought the youngsters out into the sunlight about the middle of June. Three of these years there were five youngsters. One year the number was four, and another year it was six. About
  • 61.
    the middle ofJuly the young were left to fight the battle of life alone. They were left in possession of the underground house in which they were born, and the mother went to another part of the yard, renovated another underground home, and here laid up supplies for the winter. A few days before the mother leaves the youngsters, they run about and find most of their food. One year, a day or two before the one by my cabin bade her children good-bye, she brought them—or, at any rate, the children came with her—to the place where we often distributed peanuts. The youngsters, much lighter in color, and less distinctly marked than the mother, as well as much smaller, were amusingly shy, and they made comic shows in trying to eat peanuts. They could not break through the shell. If offered a shelled nut, they were as likely to bite the end of your finger as the nut. They had not learned which was which. With their baby teeth they could eat but little of the nut, but they had the storing instinct and after a struggle managed to thrust one or two of the nuts into their cheek pockets. The youngsters, on being left to shift for themselves, linger about their old home for a week or longer, then scatter, each apparently going off to make an underground home for himself. The house may be entirely new or it may be an old one renovated. I do not know just when the mother returns to her old home. Possibly the new home is closely connected with the one she has temporarily left, and it may be that during the autumn or the early spring she digs a short tunnel which unites them. The manner of this aside, I can say that each summer the mother that I watched, on retiring from the youngsters, carried supplies into a hole which she had not used before, and the following spring the youngsters came forth from the same hole, and presumably from the same quarters, that the children of preceding years had used. Chipmunks feed upon a variety of plants. The leaves, seeds, and roots are eaten. During bloom time they feast upon wild flowers. Often they make a dainty meal off the blossoms of the fringed blue gentian, the mariposa lily, and the harebell. Commonly, in gathering flowers, the chipmunk stands erect on hind feet, reaches up with
  • 62.
    one or bothhands, bends down the stalk, leisurely eats the blossoms, and then pulls down another. The big chipmunk, however, has some gross food habits. I have seen him eating mice, and he often catches grasshoppers and flies. It is possible that he may rob birds' nests, but this is not common and I have never seen him do so. However, the bluebirds, robins, and red-winged blackbirds near me resent his close approach. A chipmunk which has unwittingly climbed into a tree or traveled into a territory close to the nest of one of these birds receives a beating from the wings of the birds and many stabs from their bills before he can retreat to a peaceful zone. Many times I have seen birds battering him, sometimes repeatedly knocking him heels over head, while he, frightened and chattering, was doing his best to escape. There are five species of chipmunks in Colorado. Two of these are near me,—the big chipmunk and the busy chipmunk. The latter is much smaller, shyer, and more lively than the former and spends a part of its time in the treetops; while the big, although it sometimes climbs, commonly keeps close to the earth. Among their numerous enemies are coyotes, wild-cats, mountain lions, bears, hawks, and owls. They appear to live from six to twelve years. The one near my place I watched for eight years. She probably was one or more years of age when I first saw her. Almost every day in summer a number of children come, some of them for miles, to watch and to feed my chipmunks. The children enjoy this as keenly as I have ever seen them enjoy anything. Surely the kindly sympathies which are thus aroused in the children, and the delightful lesson in natural history which they get, will give a helpful educational stimulus, and may be the beginning of a sympathetic interest in every living thing. A Peak by the Plains
  • 64.
    A Peak bythe Plains Pike's Peak rises boldly from the plains, going steeply up into the sky a vertical mile and a half. There is no middle distance or foreground; no terraced or inclined approach. A spectator may thus stand close to its foot, at an altitude of six thousand feet, and have a commanding view of the eight thousand feet of slopes and terraces which culminate in the summit, 14,110 feet above the sea. Its steep, abrupt ascent makes it imposing and impressive. It fronts the wide plains a vast broken tower. The typical high peak stands with other high peaks in the summit of a mountain-range. Miles of lesser mountains lie between its summit and the lowlands. Foothills rise from the edge of the lowland; above these, broken benches, terrace beyond terrace, each rising higher until the summit rises supreme. With Pike's Peak this typical arrangement is reversed. Pike's Peak probably is the most intimately known high mountain. It has given mountain-top pleasure to more people than any other fourteen thousand foot summit of the earth. One million persons have walked upon its summit, and probably two million others have climbed well up its slopes. Only a few thousand climbers have reached the top of Mont Blanc. Pike's is a peak for the multitude.
  • 65.
    PIKE'S PEAK FROMTHE TOP OF CASCADE CAÑON Climbing it is comparatively easy. It stands in a mild, arid climate, and has scanty snowfall; there are but few precipitous walls, no dangerous ice-fields; and up most of its slopes any one may ramble. One may go up on foot, on horseback, in a carriage, or by railroad, or even by automobile. It is not only easy of ascent, but also easy of access. It is on the edge of the plains, and a number of railroads cross its very foot. This peak affords a unique view,—wide plains to the east, high peaks to the west. Sixty thousand or more square miles are visible from the summit. It towers far above the plains, whose streams, hills, and level spaces stretch away a vast flat picture. To the west it commands a wondrous array of mountain topography,—a two- hundred-mile front of shattered, snow-drifted peaks. The peak is an enormous broken pyramid, dotted with high- perched lakes, cut with plunging streams, broken by cañons, skirted with torn forests, old and young, and in addition is beautiful with bushes, meadows, and wild flowers. The major part of the peak's primeval forest robe was destroyed by fire a half-century ago. Many ragged, crag-torn areas of the old forest, of a square mile or less, are connected with young growths from thirty to sixty years old.
  • 66.
    Much of thisnew growth is aspen. From the tree-studies which I have made, I learn that two forest fires caused most of the destruction. The annual rings in the young growth, together with the rings in the fire-scarred trees which did not perish, indicate that the older and more extensive of these fires wrapped most of the peak in flames and all of it in smoke during the autumn of 1850. The other fire was in 1880. Pike's Peak exhibits a number of scenic attractions and is bordered by other excellent ones. Near are the Royal Gorge, Cripple Creek, and the fossil-beds at Florissant. The Garden of the Gods, Manitou Mineral Springs, Glen Eyrie, Crystal Park, the Cave of the Winds, and Williams, Ruxton, and South Cheyenne Cañons are some of its attractions. The fossil-beds at Florissant are one of the most famous of fossil- deposits. Here was an old Tertiary lake-basin. In the deposit which filled it—a deposit of fine volcanic sand or ash, sediment, and other débris—is a wonderful array of fossilized plants and insects of a past age. All are strangely preserved for us in stone. A part of the lake appears to have been filled by a volcanic catastrophe which overwhelmed animals, plants, and insects. Whole and in fragments, they are lying where they fell. Here have been found upwards of one hundred recognizable plants, eleven vertebrate animals, and a few hundred insects. Among the fossil trees are the narrow-leaf cottonwood, the ginkgo, the magnolia, the incense cedar, and the giant redwood. Water erosion through the ages has cut deeply into these fossil-beds and worn and washed away their treasures. This deposit has been but little studied. But what it has yielded, together with the magnitude of the unexamined remainder, makes one eager concerning the extent and the nature of the treasures which still lie buried in it. Helen Hunt, whose books helped awaken the American people to the injustice done the Indian and to an appreciation of the scenic grandeur of the West, lived for many years at the foot of this peak. Much of her writing was done from commanding points on the peak. She was temporarily buried on Cheyenne Mountain, and on her
  • 67.
    former grave hasaccumulated a large cairn of stones, contributed singly by appreciative pilgrims. South Cheyenne Cañon, like Yosemite, gives a large, clear, and pleasing picture to the mind. This is due to the individuality and the artistic grouping of the beauty and grandeur of the cañon. The cañon is so narrow, and its high walls so precipitous, that it could justly be called an enormous cleft. At one point the walls are only forty feet apart; between these a road and a swift, clear stream are crowded. Inside the entrance stand the two Pillars of Hercules. These magnificent rock domes rise nearly one thousand feet, and their steep, tree-dotted walls are peculiarly pleasing and impressive. Prospect Dome is another striking rock point in this cañon. The cañon ends in a colossal cirque, or amphitheatre, about two hundred and fifty feet deep. Down one side of this a stream makes its seven white zigzag jumps. Pike's Peak wins impressiveness by standing by itself. Cheyenne Cañon is more imposing by being alone,—away from other cañons. This cañon opens upon the plains. It is a cañon that would win attention anywhere, but its situation is a most favorable one. Low altitude and a warm climate welcome trees, grass, bushes, and many kinds of plants and flowers. These cling to every break, spot, ledge, terrace, and niche, and thereby touch and decorate the cañon's grim and towering walls with lovely beauty. Walls, water, and verdure—water in pools and falls, rocks in cliffs, terraces, and domes, grass and flowers on slopes and terraces, trees and groves, —a magnificence of rocks, a richness of verdure, and the charm of running water—all unite in a picturesque association which makes a glorious and pleasing sunken garden. It is probable that Pike's Peak was discovered by Spanish explorers either in 1598 or in 1601. These are the dates of separate exploring expeditions which entered Colorado from the south and marched up the plains in near view of this peak. The discovery is usually accredited, however, to Lieutenant Pike, who caught sight of it on the 15th day of November, 1806. Pike's journal of this date says: At two o'clock in the afternoon I thought I could distinguish a mountain
  • 68.
    to our rightwhich appeared like a small blue cloud; viewed it with a spyglass and was still more confirmed in my conjecture.... In half an hour it appeared in full view before us. When our small party arrived on a hill, they with one accord gave three cheers to the Mexican Mountains. It appears not to have been called Pike's Peak until about twenty-five years after Pike first saw it. He spoke of it as the Mexican Mountains and as Great Peak. The first ascent by white men was made July 14, 1819, by members of Lieutenant Long's exploring expedition. For a number of years this peak was called James Peak, in honor of the naturalist in the Long exploring party. Pike's Peak has what Montesquieu calls the most powerful of all empires, the empire of climate. It stands most of the time in the sun. All over it the miner and the prospector have searched for gold, mutilating it here and there with holes. Fires have scarred the sides, and pasturing has robbed it of flowers and verdure. The reputed discovery of gold at its base started a flood of gold-seekers west with Pike's Peak or bust enthusiasm. But the climate and scenery of this peak attract people who come for pleasure and to seek for health. It has thus brought millions of dollars into Colorado, and it will probably continue to attract people who seek pleasure and refreshment and who receive in exchange higher values than they spend. Pike's Peak is a rich asset. The summit of Pike's Peak is an excellent place to study the effect of altitude upon lowland visitors. Individual observations and the special investigations of scientific men show that altitude has been a large, unconscious source of nature-faking. During the summer of 1911 a number of English and American scientists, the Anglo- American Expedition, spent five weeks on Pike's Peak, making special studies of the effects of altitude. Their investigations explode the theory that altitude is a strain upon the heart, or injurious to the system. These men concluded that the heart is subjected to no greater strain in high altitudes than at sea-level, except under the strain of physical exertion. The blood is richer in high altitudes. For every hundred red corpuscles found at sea-level there are in Colorado Springs, at six thousand feet, one hundred and ten; and on
  • 69.
    the summit ofPike's Peak, from one hundred and forty to one hundred and fifty-four. The danger to people suffering from heart trouble coming into high altitudes is grossly exaggerated, says Dr. Edward C. Schneider, one of the Anglo-American expedition. The rate of circulation is not materially increased. The blood-pressure on the Peak is not increased; it is even lowered. The heart—if a person exercises—may beat a little faster but it does not pump any more blood. The pulse is a little more rapid. If a man suffering from heart trouble rode up the peak on a train, remained in his seat, and did not exert himself physically, his heart would not beat a bit faster at the summit than when he left Manitou. But if he walked about on the summit there would be a change, for the exercise would make the heart work harder. But exercise is not injurious; it is beneficial. As I found in guiding on Long's Peak, the rarefied air of the heights was often stimulating, especially to the tongue. Rarefied air is likened by the scientists to laughing-gas and furnishes a plausible explanation of the queerness which characterizes the action of many people on mountain-summits. We saw many visitors at the summit, said Dr. Schneider in explaining this phase, who appeared to be intoxicated. But there was no smell of liquor on their breath. They were intoxicated with rarefied atmosphere, not with alcohol. The peculiar effects of laughing-gas and carbon-monoxide gas on people are due to the lack of oxygen in the gas; and the same applies to the air at high altitudes. The summit of Pike's Peak is roomy and comparatively level, and is composed of broken granite, many of the pieces being of large size. A stone house stands upon the top. In this for many years was a government weather-observer. A weather station has just been re- established on its summit. This will be one of a line of high weather stations extending across the continent. This unique station should contribute continuously to the weather news and steadily add to the sum of climatic knowledge. This one peak has on its high and broken slopes a majority of the earth's climatic zones, and a numerous array of the earth's countless
  • 70.
    kinds of plantand animal life. One may in two hours go from base to summit and pass through as many life zones as though he had traveled northward into the Arctic Circle. Going from base to summit, one would start in the Upper Sonoran Zone, pass through the Transition, Canadian, and Hudsonian Zones, and enter the Arctic- Alpine Zone. The peak has a number of places which exhibit the complexity of climatic zones. In a deep cañon near Minnehaha Falls, two zones may be seen side by side on opposite sides of a deep, narrow cañon. The north side of the cañon, exposed to the sun, has such plants as are found in the Transition Zone, while the cool south side has an Hudsonian flora. Here is almost an actual contact of two zones that outside the mountains are separated by approximately two thousand miles. The varied climate of this peak makes a large appeal to bird-life. Upward of one hundred species are found here. People from every part of the Union are here often startled by the presence of birds which they thought were far away at home. At the base the melodious meadowlark sings; along the streams on the middle slopes lives the contented water-ouzel. Upon the heights are the ptarmigan and the rosy finch. Often the golden eagle casts his shadow upon all these scenes. The robin is here, and also the bluebird, bluer, too, than you have ever seen him. The Western evening grosbeak, a bird with attractive plumage and pleasing manners, often winters here. The brilliant lazuli bunting, the Bullock oriole, the red-shafted flicker, and the dear and dainty goldfinch are present in summer, along with mockingbirds, wrens, tanagers, thrushes, and scores of other visitants. A few migratory species winter about the foot of the peak. In summer they fly to the upper slopes and nest and raise their young in the miniature arctic prairies of the heights. With the coming of autumn all descend by easy stages to the foot. The full distance of this vertical migration could be covered in an hour's flight. Many of the north-and-south-migrating birds travel a thousand times as far as these birds of vertical migration.
  • 71.
    The big gamewhich formerly ranged this peak included buffalo, deer, elk, mountain sheep, the grizzly, the black bear, the mountain lion, the fox, the coyote, and the wolf. Along the descending streams, through one vertical mile of altitude, were beaver colonies, terrace upon terrace. No one knows how many varieties of wild flowers each year bloom in all the Peak's various ragged zones, but there are probably no fewer than two thousand. Along with these are a number of species of trees. Covering the lower part of the mountain are growths of cottonwood, Douglas spruce, yellow pine, white fir, silver spruce, and the Rocky Mountain birch. Among the flowering plants are the columbine, shooting-star, monkshood, yucca or Spanish bayonet, and iris. Ascending, one finds the wintergreen, a number of varieties of polemonium, the paintbrush, the Northern gentian, the Western yarrow, and the mertensia. At timber-line, at the altitude of about eleven thousand five hundred feet, are Engelmann spruce, arctic willow, mountain birch, foxtail pine, and aspen. At timber-line, too, are the columbine, the paintbrush, and a number of species of phlox. There are no trees in the zone which drapes the uppermost two thousand feet of the summit, but in this are bright flowers,—cushion pinks, the spring beauty, the alpine gentian, the mountain buckwheat, the white and yellow mountain avens, the arctic harebell, the marsh-marigold, the stonecrop, and the forget-me-not. One summer I found a few flowers on the summit. Isolation probably rendered the summit of this peak less favorable for snow-accumulation during the Ice Age than the summits of unisolated peaks of equal altitude. During the last ice epoch, however, it carried glaciers, and some of these extended down the slopes three miles or farther. These degraded the upper slopes, moved this excavated material toward the bottom, and spread it in a number of places. There are five distinct cuplike hollows or depressions in this peak that were gouged by glaciers. The one lying between Cameron's Cone and the summit is known as the Crater. A part of this is readily seen from Colorado Springs. Far up the slopes are Lake Moraine and Seven Lakes, all of glacial origin.
  • 72.
    The mountain masswhich culminates in Pike's Peak probably originated as a vast uplift. Internal forces appear to have severed this mass from its surroundings and slowly upraised it seven thousand or more feet. The slow uprising probably ended thousands of years ago. Since that time, disintegration, frost, air, and stream erosion have combined to sculpture this great peak. Pike's Peak might well be made a National Park. The Conservation of Scenery
  • 73.
    The Conservation of Scenery Thecomparative merits of the Alps and the Rocky Mountains for recreation purposes are frequently discussed. Roosevelt and others have spoken of the Colorado Rockies as The Nation's Playground. This Colorado region really is one vast natural park. The area of it is three times that of the Alps. The scenery of these Colorado Rocky Mountains, though unlike that of the Alps, is equally attractive and more varied. Being almost free from snow, the entire region is easily enjoyed; a novice may scale the peaks without the ice and snow that hamper and endanger even the expert climbers in the icy Alps. The Alps wear a perpetual ice-cap down to nine thousand feet. The inhabited zone in Colorado is seven thousand feet higher than that zone in Switzerland. At ten thousand feet and even higher, in Colorado, one finds railroads, wagon-roads, and hotels. In Switzerland there are but few hotels above five thousand feet, and most people live below the three-thousand-foot mark. Timber-line in Colorado is five thousand feet farther up the heights than in Switzerland. The Centennial State offers a more numerous and attractive array of wild flowers, birds, animals, and mineral springs than the land of William Tell. The Rocky Mountain sheep is as interesting and audacious as the chamois; the fair phlox dares greater heights than the famed edelweiss. The climate of the Rocky Mountains is more cheerful than that of the Alps; there are more sunny days, and while the skies are as blue as in Switzerland, the air is drier and more energizing.
  • 74.
    THE CONTINENTAL DIVIDENEAR ESTES PARK But the attractions in the Alps are being preserved, while the Rocky Mountains are being stripped of their scenery. Yet in the Rocky Mountains there are many areas rich in perishable attractions which might well be reserved as parks so that their natural beauties could be kept unmarred. It is to be hoped that the growing interest in American scenery will bring this about before these wild mountain gardens are shorn of their loveliness.[1] [1] Since this was put into type, the Rocky Mountain National Park, after a campaign of six years, has been established, and campaigns have started to make National Parks of Mount Evans and Pike's Peak. And the Secretary of the Interior has appointed a Superintendent of National Parks and called attention to the great need of legislation for these Parks. The United States is behind most nations in making profitable use of scenery. Alpine scenery annually produces upward of ten thousand dollars to the square mile, while the Rocky Mountains are being despoiled by cattle and sawmills for a few dollars a square mile. Though Switzerland has already accomplished much along scenic conservation lines, it is working for still better results. It is constructing modern hotels throughout the Alps and is exploiting the
  • 75.
    winter as wellas the summer use of these. The Canadian Government has done and is doing extensive development work in its national parks. It is preparing a welcome for multitudes of travelers; travelers are responding in numbers. The unfortunate fact is that our scenery has never had a standing. To date, it has been an outcast. Often lauded as akin to the fine arts, or something sacred, commonly it is destroyed or put to base uses. Parks should no longer be used as pigpens and pastures. These base uses prevent the parks from paying dividends in humanity. There is in this country a splendid array of Nature's masterpieces to lure and reward the traveler. In mountain-peaks there are Grand Teton, Long's Peak, Mt. Whitney, and Mt. Rainier; in cañons, the vast Grand Cañon and the brilliantly colored Yellowstone; in trees, the unrivaled sequoias and many matchless primeval forests; in rivers, few on earth are enriched with scenes equal to those between which rolls the Columbia; in petrified forests, those in Arizona and the Yellowstone are unsurpassed; in natural bridges, those in Utah easily arch above the other great ones of the earth; in desert attractions, Death Valley offers a rare display of colors, strangeness, silences, and mirages; in waterfalls, we have Niagara, Yellowstone, and Yosemite; in glaciers, there are those of the Glacier and Mount Rainier National Parks and of Alaska; in medicinal springs, there is an array of flowing, life-extending fountains; in wild flowers, the mountain wild flowers in the West are lovely with the loveliest anywhere; in wild animals of interest and influence, we have the grizzly bear, the beaver, and the mountain sheep; in bird music, that which is sung by the thrushes, the cañon wren, and the solitaire silences with melodious sweetness the other best bird-songs of the earth. In these varied attractions of our many natural parks we have ample playgrounds for all the world and the opportunity for a travel industry many times as productive as our gold and silver mines—and more lasting, too, than they. When these scenes are ready for the traveler we shall not need to nag Americans to see America first;
  • 76.
    and Europeans, too,might start a continuous procession to these wonderlands. In the nature of things, the United States should have a travel industry of vast economic importance. The people of the United States are great travelers, and we have numerous and extensive scenic areas of unexcelled attractiveness, together with many of the world's greatest natural wonders and wonderlands which every one wants to see. All these scenes, too, repose in a climate that is hospitable and refreshing. They should attract travelers from abroad as well as our own people. The traveler brings ideas as well as gold. He comes with the ideals of other lands and helps promote international friendship. Then, too, he is an excellent counter-irritant to prevent that self-satisfied attitude, that deadening provincialism, which always seems to afflict successful people. Develop our parks by making them ready for the traveler, and they will become continuously productive, both commercially and spiritually. Our established scenic reservations, or those which may be hereafter set aside, are destined to become the basis of our large scenic industry. The present reservations embrace fourteen National Parks and twenty-eight National Monuments. Each Park and Monument was reserved because of its scenic wonders, to be a recreation place for the people. The name Monument might well be changed to Park. The Monuments were set aside by executive orders of the President; the Parks were created by acts of Congress. Each Park or Monument is a wonderland in itself. All these together contain some of the strangest, sublimest scenes on the globe. Each reservation is different from every other, and in all of them a traveler could spend a lifetime without exhausting their wonders. I suppose that in order to lead Americans to see America first, or to see it at all, and also to win travel from Europe, it is absolutely necessary to get America ready for the traveler. Only a small part of American scenery is ready for the traveler. The traveler's ultimatum contains four main propositions. These are grand scenery, excellent climate, good entertainment, and swift, comfortable transportation.
  • 77.
    When all ofthese demands are supplied with a generous horn of plenty, then, but not until then, will multitudes travel in America. Parks now have a large and important place in the general welfare, and the nation that neglects its parks will suffer a general decline. The people of the United States greatly need more parks, and these are needed at once. I do not know of any city that has park room extensive enough to refresh its own inhabitants. Is there a State in the Union that has developed park areas that are large enough for the people of the State? With present development, our National Parks cannot entertain one fifth of the number of Americans who annually go abroad. As a matter of fact, the entertainment facilities in our National Parks are already doing a capacity business. How, then, can our Parks be seen by additional travelers? For a travel industry, the present needs in America are for cities at once to acquire and develop into parks all near-by scenery; for each State to develop its best scenic places as State Parks; and for the nation to make a number of new National Parks and at once make these scenic reservations ready for the traveler. Systems of good roads and trails are necessary. In addition to these, the Parks, Monuments, and Reservations need the whole and special attention of a department of their own. A park requires eternal vigilance. The better half of our scenic attractions are the perishable ones. The forests and the flowers, the birds and the animals, the luxuriant growths in the primeval wild gardens, are the poetry, the inspiration, of outdoors. Without these, how dead and desolate the mountain, the meadow, and the lake! If a park is to be kept permanently productive, its alluring features must be maintained. If the beaver ceases to build his picturesque home, if the deer vanishes, if the mountain sheep no longer poses on the crags, if the columbine no longer opens its bannered bosom to the sun, if the solitaire no longer sings,—without these poetic and primeval charms, marred nature will not attract nor refresh. People often feel the call of the wild, and they want the wild world beautiful. They need the temples of the gods, the forest primeval, and the pure and flower-fringed brooks.
  • 78.
    It would bewell to save at once in parks and reservations the better of all remaining unspoiled scenic sections of the country,—the lake-shores and the seashore, the stream-side, the forests primeval, and the Rocky Mountains. There is a great and ragged scenic border of varying width that extends entirely around the United States. This includes the Great Lake region and the splendid Olympic Mountains at the northwest corner of the country. Inside of this border are other localities richly dowered with natural beauty and dowered, too, with hospitable climate. The Rocky Mountain region is one splendid recreation-ground. There are many beauty-spots in the Ozark Mountains of Missouri and Arkansas, and there are scenic regions in New York, Pennsylvania, and western North Carolina, and the State of Idaho embraces many scenic empires. These contain scores of park areas that will early be needed.
  • 79.
    LONG'S PEAK FROMLOCH VALE Every park is a place of refuge, a place wherein wild life thrives and multiplies. As hunters are perpetually excluded from all parks, these places will thus become sanctuaries for our vanishing wild life. All wild life quickly loses its fear and allows itself to be readily seen in protected localities. Wild life in parks thus affords enjoyment by being readily seen, and from now on this life will become a factor in education. Children who go into parks will be pleasantly compelled to observe, delightfully incited to think, and will thus become alert and interested,—will have the very foundation of education. Perhaps it is safe to predict that from now on the tendency will be to multiply the number of parks and decrease the number of zoölogical gardens. Scenic places, if used for parks, will pay larger returns than by any other use that can be made of their territory. Parks, then, are not a luxury but a profitable investment. Switzerland is supporting about half of her population through the use of her mountain scenery for recreation purposes. Although parks pay large dividends, they also have a higher, nobler use. They help make better men and women. Outdoor life is educational. It develops the seeing eye, supplies information, gives material for reflection, and compels thinking, which is one of the greatest of accomplishments. Exercise in the pure air of parks means health, which is the greatest of personal resources, and this in turn makes for efficiency, kindness, hopefulness, and high ideals. Recreation in parks tends to prevent wasted life by preventing disease and wrong-doing. The conservation of scenery, the use of scenic places for public recreation parks, is conservation in the highest sense, for parks make the best economic use of the territory and they also pay large dividends in humanity. The travel industry is a large and direct contributor to many industries and their laborers. It helps the railroads, automobile- makers, hotels, guides, and the manufacturers of the clothing, books, souvenirs, and other articles purchased by travelers. Perhaps the farmer is the one most benefited; he furnishes the beef, fruit,
  • 80.
    butter, chickens, andin fact all the food consumed by the traveling multitude. A large travel industry means enlarging the home market to gigantic proportions. The courts have recently expressed definite and advanced views concerning scenic beauty. In Colorado, where water has a high economic value, a United States Circuit Court recently decided that the beneficial use of a stream was not necessarily an agricultural, industrial, or commercial use, and that, as a part of the scenery, it was being beneficially used for the general welfare. The question was whether the waters of a stream, which in the way of a lakelet and a waterfall were among the attractions of a summer resort, could be diverted to the detriment of the falls and used for power. The judge said No, because the waters as used, were contributing toward the promotion of the public health, rest, and recreation; and that as an object of beauty—just to be looked at—they were not running to waste but were in beneficial use. He held that objects of beauty have an important place in our lives and that these objects should not be destroyed because they are without assessable value. The judge, Robert E. Lewis, said in part:— It is a beneficial use to the weary that they, ailing and feeble, can have the wild beauties of Nature placed at their convenient disposal. Is a piece of canvas valuable only for a tentfly, but worthless as a painting? Is a block of stone beneficially used when put into the walls of a dam, and not beneficially used when carved into a piece of statuary? Is the test dollars, or has beauty of scenery, rest, recreation, health and enjoyment something to do with it? Is there no beneficial use except that which is purely commercial? This decision is epoch-marking. Taken as a whole, our National Parks and Monuments and our unreserved scenic places may be described as an undeveloped scenic resource of enormous potential value. These places should be developed as parks and their resources used exclusively for recreation purposes. Thus used, they would help all interests and reach all people. South America, Switzerland, Canada, and other
  • 81.
    countries are makingintensified and splendid use of their parks by reserving that wild scenic beauty which appeals to all the world. Parks are dedicated to the highest uses. They are worthy of our greatest attentions. It is of utmost importance that the management of Forest Reserves and the National Parks be separate. In 1897 the National Academy of Sciences in submitting a plan for the management of the Forest Reserves recommended that places specially scenic be separated from the Forest Reserves and set aside as Parks and given the separate and special administration which parks need. If scenery is to be saved, it must be saved for its own sake, on its own merits; it cannot be saved as something incidental. Multitudes will annually visit these places, provided they be developed as parks and used for people and for nothing else. Grazing, lumbering, shooting, and other commercial, conflicting, and disfiguring uses should be rigidly prohibited. Scenery, like beauty, has superior merit, and its supreme use is by people for rest and recreation purposes. Switzerland after long experience is establishing National Parks and giving these a separate and distinct management from her forest reserves. For a time Canadian National Parks were managed by the Forest Service. Recently, however, the parks were withdrawn from the Forest Service and placed in a Park Department. This was a most beneficial change. Forestry is commercial, radically utilitarian. The forester is a man with an axe. Trees to the forester mean what cattle do to the butcher. Lumber is his product and to recite Woodman, Spare that Tree! to a forester would be like asking the butcher to spare the ox. The forester is a scientific slaughterer of the forest; he must keep trees falling in order to supply lumber. A forester is not concerned with the conservation of scenery. Then, too, a forester builds his roads to facilitate logging and lumbering. The Park man builds roads that are scenic highways, places for people. We need the forest reserve, and we need the National Park. Each of these serves in a distinct way, and it is of utmost importance that each be in charge of its specialist. The forester is always the
  • 82.
    lumberman, the parkman is a practical poet; the forester thinks ever of lumber, the park man always of landscapes. The forester must cut trees before they are over-ripe or his crop will waste, while the park man wants the groves to become aged and picturesque. The forester pastures cattle in his meadows, while the park man has only people and romping children among his wild flowers. The park needs the charm of primeval nature, and should be free from ugliness, artificiality, and commercialism. For the perpetuation of scenery, a landscape artist is absolutely necessary. It would be folly to put a park man in charge of a forest reserve, a lumbering proposition. On the other hand, what a blunder to put a tree-cutting forester in charge of a park! We need both these men; each is important in his place; but it would be a double misfortune to put one in charge of the work of the other. A National Park service is greatly needed. Apparently William Penn was the first to honor our scenery, and Bryant, with poetry, won a literary standing for it. Official recognition came later, but the establishment of the Yellowstone National Park was a great incident in the scenic history of America—and in that of the world. For the first time, a scenic wonderland was dedicated as a public park or pleasure ground for the benefit and enjoyment of all the people. The Yellowstone stands a high tribute to the statesmanship, the public spirit, and the energy of F. V. Hayden and the few men who won it for us. During the last few years the nation, as well as the courts, has put itself on record concerning the higher worth of scenery. The White House conference of governors recommended that the beauty ... of our country should be preserved and increased; and the first National Conservation Commission thought that public lands more valuable for conserving ... natural beauties and wonders than for agriculture should be held for the use of the people. The travel industry benefits both parties,—the entertained as well as the entertainer. Investments in outdoor vacations give large returns; from an outing one returns with life lengthened, in livelier spirits, more efficient, with new ideas and a broader outlook, and more hopeful and kind. Hence parks and outdoor recreation places
  • 83.
    are mighty factorsfor the general welfare; they assist in making better men and women. A park offers the first aid and often the only cure for the sick and the overworked. Looking upon our sublime scenes arouses a love for our native land and promotes a fellow feeling. Nature is more democratic even than death; and when people mingle amid primeval scenes they become fraternal. Saving our best scenes is the saving of manhood. These places encourage every one to do his best and help all to live comfortably in a beautiful world. Scenery is our noblest resource. No nation has ever fallen from having too much scenery. The Rocky Mountain National Park
  • 84.
    The Rocky Mountain NationalPark Extend a straight line fifty-five miles northwest from Denver and another line sixty miles southwest from Cheyenne and these lines meet in approximately the centre of the Rocky Mountain National Park. This centre is in the mountain-heights a few miles northwest of Long's Peak, in what Dr. F. V. Hayden, the famous geologist, calls the most rugged section of the Continental Divide of the Rocky Mountains. This Park is a mountain realm lying almost entirely above the altitude of nine thousand feet. Through it from north to south extends the Snowy Range,—the Continental Divide,—and in it this and the Mummy Range form a vast mountain Y. Specimen Mountain is the north end of the west arm of this Y, while Mummy Mountain is at the tip of the east arm. Mt. Clarence King on the south forms the base of the stem, while Long's Peak is against the eastern side of the stem, about midway.
  • 85.
    Welcome to ourwebsite – the perfect destination for book lovers and knowledge seekers. We believe that every book holds a new world, offering opportunities for learning, discovery, and personal growth. That’s why we are dedicated to bringing you a diverse collection of books, ranging from classic literature and specialized publications to self-development guides and children's books. More than just a book-buying platform, we strive to be a bridge connecting you with timeless cultural and intellectual values. With an elegant, user-friendly interface and a smart search system, you can quickly find the books that best suit your interests. Additionally, our special promotions and home delivery services help you save time and fully enjoy the joy of reading. Join us on a journey of knowledge exploration, passion nurturing, and personal growth every day! ebookbell.com