ColdFusion Tips and Tutorials

ColdFusion Tips and Tutorials. Tips on ColdFusion, AJAX, CSS, JavaScript, HTML, Design, and more.

CFUnited Developer Conference 2010
Use this code TIPSCUST to get $100 off your registration @ CFUnited! We'll see you There!


ColdFusion Tips
Page 1 2 3
148 ColdFusion, Ajax, FuseBox, Tips, and Tut
147 Included Point of View
146 Javascript - OnFocus
145 Nathan's Rules of Professional Web Desig
144 Universal Server-Side Check | Bandwidth
143 Meeting Schedule | Identification Sessio
142 Breaking Frames Without Javascript
141 Unreal Forms
140 Screen Resolution
139 Human Help
138 Better Server-Side Validation
137 Automatic Server-Side Validation
136 Regular Expression Laboratory,ColdFusion
135 Rank-Ordered Site Search
134 Building Cryptograms
133 Well-Formed Includes
132 Grouping Families for Visits
131 Display Families on a Map Grid
130 Slide Shows
129 Determine Your Database Engine
128 ColdFusion in Context: Maxlength Lies
127 Something Extra
126 Parsing Database Structure from Data Def
125 Valid Values Maintenance
124 Print 1
123 Hide Session Id
122 Downsizing Data to Access
121 Time to Load a Page, FuseBox 4
120 Order and Rank by Subset
119 Warn through E-mail & Update on Paste Sp
118 Paste Spreadsheets, ColdFusion Component
117 Review Files Having Fixed-Length Fields
116 Organized Help
115 Sequence Slider
114 Bad Bits
113 Logical Deduction
112 Whiteout
111 Forced Navigation
110 Managing Permissions
109 Time Travel
108 Test First
107 Get Distance Between Map Coordinates
106 Validating Checkboxes
105 Matrix Manipulation
104 Field Help
103 Fake Object Not Found
102 Rank Order Correlation Coefficient
101 From Calling Pairs to Calling Tree
100 Posting Notice
99 Logout Persuasion
98 Release Session Memory
97 Use Identically Named Fields
96 Web Bug
95 Password Generation
94 Core Queries
93 Use CFFTP
92 Insert, Update, and Delete
91 Stack
90 T-Value
89 Bulk Data Entry and E-mail Validation
88 Quick Reset
87 Design 1
86 Use CFFTP
85 Support Login with AutoPost
84 Login and Site Protection
83 XY Graphs in a Graphing Calculator
82 Read Encrypted Files
81 Showing Progress
80 Frugal Cross-Browser Javascript
79 Tabbed Folders
Page 1 2 3



Custom Search
ColdFusion TIPS PLUS


Issue 00091 http://www.cftipsplus.com

I. My Comments

II. ColdFusion In Context: Stack
By R. Martin Ladner
martin.ladner@knology.net



See our sponsors at the bottom of this e-mail.

I. Comments:

Fun, Fun, my internet connection went down again... Moving is always a pain but some things are worse then others.

Thanks and Keep Coding,
Nathan Stanford
President/CEO
http://www.cftipsplus.com
http://www.htmlostips.com

If you have suggestions for articles send them to us.
If you would like to write for cftipsplus.com
send us an email to:

admin@cftipsplus.com

IF YOU WANT TO BE AN AUTHOR SEND IN YOUR COLDFUSION TIPS.

Remember this is a great way to get your name known in the
ColdFusion Community.


If you have any suggestions please email me at cftips@nsnd.com.


II. ColdFusion in Context: Stack
By R. Martin Ladner
martin.ladner@knology.net



Suppose you wanted to implement an algorithm that uses a stack. For example, one approach to a depth-first walk through a tree uses a stack. This tip shows one way that ColdFusion easily supports stack manipulation.

The major stack operations are "push" to add something to the stack (as when a food handler adds plates to a spring-loaded plate holder at a cafeteria), read (to examine the topmost item), and "pop" to remove the item most recently added. It turns out that ColdFusion has functions that readily use lists as stacks.

Stack 'Em
To show how this works, you'll need manipulation logic and an entry form. Call this code stack.cfm. If the user has activated the form, then the value returned by its submit buttons (both named "doit") will be defined. For ease of use, the form variable "stack" is converted to a local variable "myStack", then back again so the form can carry its modified value to the next use of the form.
Three ColdFusion functions seem to be made for working with stacks. If an item needs to be removed from the stack, the ListRest function does quite nicely. Ignoring the first value, it returns the rest of the list. If an item needs to be added, the ListPrepend function pushes a value onto the begining of the list. If the top-most item is required, the ListFirst function does this nicely. Each of these functions has similar syntax. The first parameter is the list name; the last parameter, the list of delimiters, can be omitted if a bare comma (no space) is used as the delimiter. For clarity, a delimiter other than a comma is used for this demonstration.

After manipulation, the form itself is displayed, preceded by the value of the top-most item (if applicable) and the value of the stack itself.


<cfif isDefined("form.doit")>
<cfset myStack=form.stack>
<cfif form.doit is "Pop">
<cfif ListLen(myStack,";")>
<cfset myStack=ListRest(myStack,";")>
<cfelse>
The stack is already empty.
</cfif>
<cfelse>
<cfif len(form.Item)>
<cfset myStack=ListPrepend(myStack,form.Item,";")>
<cfelse>
Enter an item prior to pressing "Push". No action was taken.
</cfif>
</cfif>
<cfelse>
<cfset myStack="">
</cfif>

<cfif ListLen(myStack,";")>
The top-most item is <cfoutput>#ListFirst(myStack,";")#</cfoutput><br>
</cfif>

The stack is [<cfoutput>#myStack#</cfoutput>].<br>
<form name="modstack" action="stack.cfm" method="post">
Remove an item...<input type="submit" name="doit" value="Pop"><br>
or Push this item: <input type="text" name="item" value="">
<input type="submit" name="doit" value="Push">
<input type="hidden" name="stack" value=<cfoutput>"#myStack#"</cfoutput>>
</form>

Watch 'Em
Browse stack.cfm. Push items onto the stack; remove items from the stack. Then consider how you will use stacks to support your applications.
=Marty=



Publisher and Creator:
Nathan Stanford,
admin@cftipsplus.com

http://www.cftipsplus.com


Macromedia and ColdFusion are U.S. registered trademarks.


Copyright (c) 2000 - 2002
CFTIPSPLUS.COM and NSND.COM

Permission is granted to circulate this publication via
MANUAL forwarding by email to friends provided that the text is
forwarded in its entirety and no fee is charged.

Photo of Nathan Stanford
Nathan Stanford
LinkedIn

R. Marty Ladner's
Site