Welcome!

ColdFusion Authors: Yakov Fain, Pat Romanski, Liz McMillan, Maureen O'Gara, Greg Ness

Related Topics: ColdFusion

ColdFusion: Article

Ask The Training Staff

Ask The Training Staff

I hope that all of you are enjoying your summer and getting in plenty of R&R. If you aren't, I hope you have at least upgraded to the new CF Server 5.0.

Not that this is better than a week at the beach, but it should certainly bring a little joy into your life because of some of the new features! Anyway, upgrade if you haven't already, start playing with the new features, and keep those questions coming. Here are some I've answered recently.

Q: How can I use CF to dynamically generate (out- put) special ASCII characters, such as the tab or line break characters?
A: The easiest way to do this is by using the Chr() function. Simply plug in the ASCII value of the character you want generated. For example, for a tab character, use #chr(09)# in your code. If you're not sure what the ASCII code is for the character you want, use this simple code to loop through all the values:

<cfoutput>
<cfloop from="1" to="256" index="i">
ASCII Code #i#: #chr(i)#<br>
</cfloop>
</cfoutput>
Q: You said in your class to avoid using a text file as a data source, but I have a situation where I need to do that. How do I use a text file as a data source in CF?
A: Even though it's a bad situation, it's a good question. The first thing you need to understand is how to create the data source. When creating the data source in the CF Administrator, avoid the temptation to point it to the actual file. Create your data source so it's pointing only to the subdirectory that the file is in. If you point it to the actual file, the connection will fail.

Once the data source is created in CF, you can query the file using the CFQUERY tag as you would for any other database. The biggest difference is in the FROM clause in your SQL. Here's where you'll use the name of the file. For example:

<CFQUERY NAME="MyQuery" DATASOURCE="TextTest">
SELECT Column1, Column2, etc...
FROM MyTextData.txt
</CFQUERY>
Q: In CF Studio, when I go to click on one of the resource tabs (like the database tab), it frequently unlocks the tab from the rest of the resource area, which is really annoying. Is there a way to stop this?

A: I know exactly what you mean and I agree that it's very annoying! If you're using Studio 4.5.2 there's a way to stop this "feature." Go to the Options menu and choose Settings. In the lower-right corner of the main screen there's an option called "Lock Tabs". If you check this box, your resource tabs will stay where they are and your life will be less stressful!

Q: I've upgraded to CF Server 5.0 and am trying to view the examples for the new CFGRAPH tag, but nothing ever shows up. What am I doing wrong?
A: The CFGRAPH tag is a cool addition to Cold-Fusion, but it doesn't work unless you start a separate service called the ColdFusion Graphing Server. By default this service is not started automatically. If you're running Windows NT or 2000, go to the Service Manager, start the service, and then try the examples. They should work now.

Q: What's the best way to clear out a cached query?
A: It depends on how you cached it. If you used the CACHEDWITHIN attribute of the CFQUERY tag, you can run the same query with CACHEDWITHIN="#CreateTimeSpan(0,0,0,0)#". This will refresh the query. If you cached the query using a persistent variable scope, such as session or application, you can use the StructDelete() function to remove the query from the scope. For example, if you cached the query using something like <cfquery name= "Application.MyQuery"...>, you can delete it using this statement:

<cfset tmp = StructDelete-(Application,"MyQuery")>
Please send your questions about ColdFusion (CFML, CF Server, or CF Studio) to AskCFDJ@sys-con.com. Please visit our archive site at www. NetsiteDynamics.com/AskCFDJ.

More Stories By Bruce Van Horn

Bruce Van Horn is president of Netsite Dynamics, LLC, a certified ColdFusion developer/instructor, and a member of the CFDJ International Advisory Board.

Comments (0)

Share your thoughts on this story.

Add your comment
You must be signed in to add a comment. Sign-in | Register

In accordance with our Comment Policy, we encourage comments that are on topic, relevant and to-the-point. We will remove comments that include profanity, personal attacks, racial slurs, threats of violence, or other inappropriate material that violates our Terms and Conditions, and will block users who make repeated violations. We ask all readers to expect diversity of opinion and to treat one another with dignity and respect.