I am programmatically getting the path to the root of the site, and I
want to make sure that if the last character in the path is a slash
(\) that it's removed. That's cos when i combine the root path
vaiable with other variables i want to make sure there is only a
single \ anywhere.
I have this in my application.cfm:
<cfset temprootpath = GetDirectoryFromPath(GetCurrentTemplatePath()) />
which gives me something like
c:\inetpub\wwwroot\
so how to remove the trailing slash?
--
Cheers
Mike Kear
Windsor, NSW, Australia
Adobe Certified Advanced ColdFusion Developer
AFP Webworks
http://afpwebworks.com
ColdFusion, PHP, ASP, ASP.NET hosting from AUD$15/month
<cfif string.endsWith('\')>
<cfset string = left(string, Len(string) - 1 ) />
</cfif>
Andrew Scott
Senior Coldfusion Developer
Aegeon Pty. Ltd.
www.aegeon.com.au
Phone: +613 8676 4223
Mobile: 0404 998 273
That is a fucntion that can't be found in my CF MX 6.1 manual.
>>> andrew...@aegeon.com.au 06/12/2006 4:24 pm >>>
Use this instead...
<cfif right(string,1) is '/'>
<cfset string = left(string, Len(string) - 1 ) />
</cfif>
Bruce
And nor will you either, if you think about it CF sees that as a string and
Java has the method endsWith() so you can leverage of this little trick with
great uses:-)
<cfif right(string, 1) EQ "/">
....
</cfif>
-----Original Message-----
From: cfau...@googlegroups.com [mailto:cfau...@googlegroups.com]On
Behalf Of Scott Thornton
Sent: Wednesday, 6 December 2006 4:31 PM
To: cfau...@googlegroups.com
Subject: [cfaussie] Find and remove a trailing slash from a path - brain
fade time
I'm assuming endsWith() is a java string function is it? Where can
i find a list of all these functions? I ought to know more about
them.
Cheers
Mike Kear
Windsor, NSW, Australia
Adobe Certified Advanced ColdFusion Developer
AFP Webworks
http://afpwebworks.com
ColdFusion, PHP, ASP, ASP.NET hosting from AUD$15/month
Robin
But I do think that Andrew's java answer was really cool.
Cheers
Mike Kear
Windsor, NSW, Australia
Adobe Certified Advanced ColdFusion Developer
AFP Webworks
http://afpwebworks.com
ColdFusion, PHP, ASP, ASP.NET hosting from AUD$15/month
I agree. There are lots of interesting undocumented methods hanging
around in CFML - For instance application.getApplicationSettings()
that I blogged about back in 2005:
http://www.rocketboots.com.au/blog/index.cfm?
mode=entry&entry=8A1C48F5-E081-51EF-A7AF8C312529DABA
Here's a script ("Java Eye for the CF Guy"?) that lists some of the
methods hidden away in common-garden CFML things:
<cfapplication name="test" sessionmanagement="true">
<cfscript>
function hiddenMethods(class) {
writeOutput("<h1>Class: " & class.toString() & "</h1><br>");
aMethods = class.getMethods();
for (i = arrayLen(aMethods); i gt 0; i = i - 1)
writeOutput(aMethods[i].toString() & "<br>");
}
// String
s = "hello";
hiddenMethods(s.getClass());
// Array
hiddenMethods(arrayNew(1).getClass());
// XML
hiddenMethods(xmlNew().getClass());
// Struct
hiddenMethods(structNew().getClass());
// Application
hiddenMethods(application.getClass());
// Session
hiddenMethods(session.getClass());
// Template
hiddenMethods(getClass());
// Component
function getClassFromInsideComponent() {
return getClass();
}
instance = createObject("component","WEB-INF.cftags.component");
instance.getClassFromInsideComponent = getClassFromInsideComponent;
hiddenMethods(instance.getClassFromInsideComponent());
</cfscript>
As always, use undocumented methods at your own risk :-)
______________
Robin Hilliard
Director - RocketBoots Pty Ltd
Consulting . Recruitment . Software Licensing . Training
http://www.rocketboots.com.au
For schedule/availability call Pamela Higgins:
w +61 7 5451 0362
m +61 419 677 151
f +61 3 9923 6261
e p...@rocketboots.com.au
or Direct:
m +61 418 414 341
e ro...@rocketboots.com.au