• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Function is not returning value of the correct type

Community Beginner ,
Aug 24, 2006 Aug 24, 2006

Copy link to clipboard

Copied

I am setting up a ColdFusion component to rotate banner ads. The code (borrowed very heavily from Ben Forta's Web Application Kit) works well ... except after it's rotated through all the ads (I have four right now), I get an error: "The value returned from function CurrentAdId() is not of type numeric."

I'm not sure how much of the code you will need to see, so I'm pasting all of it here. I apologize if it's way more than necessary, and will appreciate any help you can offer! --diane

TOPICS
Advanced techniques

Views

390

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Aug 24, 2006 Aug 24, 2006

Copy link to clipboard

Copied

Here is the dirty fix, I'm heading off to sleep.

If the function CurrentAdId doesn't return a number, then this will ensure it returns 0 (prevents your error, may not display an ad):

<CFFUNCTION
NAME="CurrentAdId"
ACCESS="Private"
RETURNTYPE="numeric"
HINT="For internal use. Returns the Id of the current ad in rotation.">

<!--- Return the adId from the current row of the GetAdIds query --->
<cfset var returnVal = ListGetAt(THIS.AdList, THIS.CurrentListPos)>

<cfif NOT IsNumeric(returnVal)>
<cfset returnVal = 0>
</cfif>

<CFRETURN returnVal>
</CFFUNCTION>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 25, 2006 Aug 25, 2006

Copy link to clipboard

Copied

LeftCorner: I can see where this *should* have worked, but it did not. Same error message. --diane

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Aug 26, 2006 Aug 26, 2006

Copy link to clipboard

Copied

LATEST
The function CurrentAdId() returns an item from a list. Apparently, the list comprises strings. I would therefore change the return-type to "Any" or "String".

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation