Skip to main content
Inspiring
April 18, 2008
Question

Why is the number 2 displayed?

  • April 18, 2008
  • 8 replies
  • 599 views
Hi all,
I´m confused trying to work out why the code arg2 in hash signs displays the number 2? I can´t see a 2 anywhere- Is the fntest doing a len function? Thank-you very much
This topic has been closed for replies.

8 replies

BKBK
Community Expert
Community Expert
April 22, 2008
Hydrowizard, we all have those moments. I know I have.

Inspiring
April 20, 2008
> I can?t see a 2 anywhere

> <CFOUTPUT>#fnTest[1,2]#

What, even in the line of code I quote above? You can't see a "2" in that?

Let's stipulate that you've noted everyone else's advice and recoded that
to be valid:

#fnTest(1,2)#

You are passing "2" as the second argument into a function, which you've
instructed to be called "arg2". Then you output the value of "arg2". How
is it a mystery to you that when you set a variable to have a value of "2"
that when you output it, a "2" appears?

--
Adam
Inspiring
April 22, 2008
Thank you all for the replies, that makes sense now , cheers
Inspiring
April 19, 2008
Because it comes after the first comma.
Inspiring
April 19, 2008
why is the second argument value 2? Where is that defined?
Inspiring
April 19, 2008
<CFOUTPUT>#fnTest[1,2]#

is this how you call the function? why are those square brackets instead
of ( and )? where's the closing </CFOUTPUT>?

anyways, those look like a 1 and a 2 to me, but maybe not everyone can
see a 2 for a 2...

Azadi Saryev
Sabai-dee.com
http://www.sabai-dee.com/
Inspiring
April 18, 2008
This line, #fntest[1,2]# called the function and the value of the 2nd argument is 2.
I didn't realize you could call a function with square brackets though.
Inspiring
April 19, 2008
but why is the value of the second argument 2? I just can´t see where!! The fntest second value? The cfargument is like a cfparam for functions vif i understand right- sorry just really confused thanks
Inspiring
April 18, 2008
Ian Skinner wrote:
>
> Unfortunately you just ran into a peril of a stateless language.

Loosely typed language.

This is not an issue with the stateless nature of HTTP requests and
responses, but rather that CFML is loosely typed and does not enforce
the typing of variables.

Inspiring
April 18, 2008
Hydrowizard wrote:

<CFOUTPUT>#fnTest[1,2]#

[] Square brackets are for arrays.

() Parentheses are for parameters for a function.

Change that to: #fnTest(1,2)#

Unfortunately you just ran into a peril of a stateless language.

ColdFusion happily let you redefine the variable 'fnTest' from a
function to a two element, one dimension array without a bit of notice
or complaint.