EasyCFM.COM ColdFusion Forums / Coding Help! / ReplaceNoCase prob

   Reply to Discussion | New Discussion << previous || next >> 
Posted By Discussion Topic: ReplaceNoCase prob -- page: 1 2

book mark this topic Printer-friendly Version  send this discussion to a friend  new posts last

Lossed
01-25-2005 @ 10:15 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Senior Member
Posts: 1095
Joined: Apr 2004

Do a query, get a result, want to display the result without any "_"'s in it. Thought, no probs, will just replace them all with blank spaces but can't seem to get it to work.

I have this in an output block:

Welcome to our #ReplaceNoCase(qDetails.TypeName, "_", " ", "ALL")# Index

The error I get says:

When using named parameters to a function, every parameter must have a name.
The CFML compiler was processing:

an expression beginning with "ReplaceNoCase", on line 61, column 25.This message is usually caused by a problem in the expressions structure.
The body of a cfoutput tag beginning on line 57, column 26.
The body of a cfoutput tag beginning on line 57, column 26.

Anyone have any ideas where I'm going wrong with this?

Tks,
Lossed
---------------------------
When the only tool you have is a hammer, everything looks like a nail Smile
-----------------------------

newkirk
01-25-2005 @ 10:34 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Senior Member
Posts: 237
Joined: Oct 2004

I have had that error for 2 reasons:
1> I forgot to put #'s around variables in a function
OR
2> I forgot to put " around strings

Stay Classy Smile
http://photoshare.blueflydatadesign.com

ShytKicker
01-25-2005 @ 10:40 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Junior Member
Posts: 140
Joined: Jan 2005

Copy paste this:

#rereplacenocase('#qdetails.typename#', '_', ' ', 'ALL')#

I did a few things, first it must be rereplace if you want to replace more than once. I put typename under quotes and changed to single quotes because I don't know the rest of your code.

This message was edited by ShytKicker on 1-25-05 @ 10:40 PM

JJfutbol
01-25-2005 @ 11:59 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Moderator
Posts: 1250
Joined: Nov 2004

It has to be a REReplaceNoCase so that it can replace it more then once if it appears more then once?? But I've read that ReplaceNoCase can do the same, if you set the fourth paramter to ALL it'll replace every item you specify it to replace. Maybe the _ is a special character and you have to use the REReplaceNoCase?? Did it work for you Lossed?? Let us know.

We will come... We will play... We will conquer... We are Laziales!!... Fear us.

ShytKicker
01-26-2005 @ 12:51 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Junior Member
Posts: 140
Joined: Jan 2005

There is no such thing as replacenocase. The only ones that exist are replace, rereplacenocase, and rereplace.

Lossed
01-26-2005 @ 1:58 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Senior Member
Posts: 1095
Joined: Apr 2004

This works:

#ReplaceNoCase(TypeName, '_', ' ', 'All')#

but using double quotes where there are single quotes doesn't work. Why not?

My CF book uses double quotes.

Tks,
Lossed
---------------------------
When the only tool you have is a hammer, everything looks like a nail Smile
-----------------------------

ShytKicker
01-26-2005 @ 2:23 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Junior Member
Posts: 140
Joined: Jan 2005

Maybe because of the code that surrounds it. Are you sure you are not using rereplacenocase? I have a hard time believing that replacenocase exists.

Lossed
01-26-2005 @ 4:09 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Senior Member
Posts: 1095
Joined: Apr 2004

Go to your local docs and search replacenocase and you will find the function, along with replace.
I do not understand your reply about the double quotes. Can you please explain it in more detail, like what could cause the need for the single quotes rather than double quotes?

Tks,
Lossed
---------------------------
When the only tool you have is a hammer, everything looks like a nail Smile
-----------------------------

ShytKicker
01-26-2005 @ 11:57 AM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Junior Member
Posts: 140
Joined: Jan 2005

Give me the 5 lines surrounding the code, and I will tell you why.

If it is in a <cfset> tag or any tag then you must escape other double quotes with single quotes. But maybe you made a mistake somewhere, let me see some lines surrounding the code so I can tell you exactly what it was.

Also, you would want to use REreplacenocase, because with replacenocase it only replaces the first "_" in the string. With rereplacenocase, it will replace every "_" in the string.

Lossed
01-26-2005 @ 2:55 PM
Reply
Edit
Profile
Send P.M.
My Gravatar!
Powered by Gravatar
Senior Member
Posts: 1095
Joined: Apr 2004

Tks for your help. Please don't get me wrong, I'm grateful for the solution but some of what you have been saying just doesn't seem to ring true.

Did you actually try the replacenocase function or read your local docs? It DOES replace all, the default is the first occurance, but if you add 'All' as I have done, it replaces all.
I'm still unclear about the single or double quotes.
My CFM book uses double quotes but when I do exactly the same, it doesn't work.
If I have just this code below in a page, it won't work:
<cfset ClassName="Consumer_Electronics_Yeah_Baby_Yeah">
<cfoutput>variables.ClassName : #ReplaceNoCase(variables.ClassName, "_", " ", "All")#</cfoutput>
But if I change to single quotes, this works:
<cfset ClassName="Consumer_Electronics_Yeah_Baby_Yeah">
<cfoutput>variables.ClassName : #ReplaceNoCase(variables.ClassName, '_', ' ', 'All')#</cfoutput>

I musn't be looking hard eough through my local docs because I can't find the reason.
There is no other code on the page, just those few lines.

Anyone got any ideas?



Tks,
Lossed
---------------------------
When the only tool you have is a hammer, everything looks like a nail Smile
-----------------------------

PAGE: 1 2

Website Designed and Developed by Pablo Varando.