Skip to main content
Inspiring
May 23, 2006
Answered

CFFunction

  • May 23, 2006
  • 5 replies
  • 1772 views
This is a weird error.

I have a template that includes a bunch of include files. Two of them are custom functions:
includes "ScientificFormat.cfm" and "SetMOA.cfm".

The ScientificFormat function/include works fine until I try to call SetMOA.cfm. At that point, I get the error:
Routines cannot be declared more than once.
The routine "scientificFormat" has been declared twice in different templates.

I know that ScientificFormat is not called anywhere in the page that use the SetMOA function (TMOA.cfm). I comment out the
include files in TMOA.cfm and the code runs fine. What it seems to boil down to is that I can make a call to SetMOA on
TMOA.cfm, but not in any files included in TMOA.cfm.

Am I calling the function right, or doing somethng wrong. I'm trying to pass one parameter to the function:

TMOA.CFM - Works Fine
<CFSET SetMOA(31)/>

TMOA.CFM

<cflinclude template = "esters.cfm">

Esters.cfm - doesn't work:
<CFSET SetMOA(32)/>
    This topic has been closed for replies.
    Correct answer James74
    Figured it out- a big "Dah" on my part. I was moving include files around and they were not pointing to the correct files.

    5 replies

    James74AuthorCorrect answer
    Inspiring
    May 23, 2006
    Figured it out- a big "Dah" on my part. I was moving include files around and they were not pointing to the correct files.
    James74Author
    Inspiring
    May 23, 2006
    Hi Phil,

    Thanks for the reply.

    Yes, that's right on. There are about 10 include files in the main page, and each need to call the setmoa() function. It works fine if I include the actual code right in the main page, but if I break it into includes, I get the error. The other includes on this page don't have other includes, but the main page is included in a page that's included in a page etc.. However, this is the only place that uses that function. I have other functions included in templates and they work fine, that's what's so weird about it.

    I have even commented out the other includes and made a test include that only tries to call the function, and it still errors.
    James74Author
    Inspiring
    May 23, 2006
    Can't figure this one out. The closest info I found was to make sure your function is only declared once. Does anyone know how to do that?
    Participating Frequently
    May 23, 2006
    Do any of your include files have includes of their own? In other words, could you be including two incude files that may each be including the same other template?

    Phil
    James74Author
    Inspiring
    May 23, 2006
    Hi Dan,

    The function is in a separate template and that's included on the main template page named ChemicalProperties.cfm:
    <cfinclude template = "SetMOA.cfm">

    The chemical properties page also includes a page named TMOA.cfm. The SetMOA function works fine when called directly in TMOA.cfm. However, TMOA holds thousands of lines of code, so I broke it up into groups and include each group's code as a separate template in TMOA.cfm.

    IF I paste one of the group's chunk of code directly in TMOA.cfm, it works fine. But if I include the code as a template, I get the above error. I've tried including the Setmoa.cfm template separately in each group's page as well, but still get the error. I'm trying <CFSET Tmp = SetMOA()> instead of just
    <CFSET SetMOA()\> to see if that is the problem. I can't think of anything else that could cause this problem.
    Inspiring
    May 23, 2006
    Put the function in a separate template and cfinclude that template.