Skip to main content
Inspiring
June 6, 2008
Answered

Using "-" in a variable without calculating

  • June 6, 2008
  • 1 reply
  • 364 views
This should be an easy one... when I have a # in the output, to cancel it out, I add another one (ie. color=##ffffff). But I'm having problems with the same type of thing if I use a hyphen/minus sign "-".

I have three variables that I'm trying to merge as:

#variable1#-#variable2#-#variable3#

so the number when I do CFSET should be something like

1234-5678-9000

I tried adding another - sign and it just calculates that too.

But if I try to set that as a variable, it does the calculation instead. I hope this makes sense :)

Is there a way to cancel out the - so it doesn't calculate it and just places it in the variable? I'm using CF 5.

Thanks!
This topic has been closed for replies.
Correct answer Newsgroup_User
> I have three variables that I'm trying to merge as:
>
> #variable1#-#variable2#-#variable3#

Doing that you're treating them like numeric values with the minus operator
bewteen them, hence it's interpretting the expression literally.

What you need to do it to consider that what you're trying to do is to
create a string. So you need to put string-delimiters around the
expression, or use the string-concatenation operator:

"foo bar"

or

"foo" & " " & "bar"

--
Adam

1 reply

Newsgroup_UserCorrect answer
Inspiring
June 6, 2008
> I have three variables that I'm trying to merge as:
>
> #variable1#-#variable2#-#variable3#

Doing that you're treating them like numeric values with the minus operator
bewteen them, hence it's interpretting the expression literally.

What you need to do it to consider that what you're trying to do is to
create a string. So you need to put string-delimiters around the
expression, or use the string-concatenation operator:

"foo bar"

or

"foo" & " " & "bar"

--
Adam
ltherAuthor
Inspiring
June 6, 2008
Aaaah! There we go! That worked. Thanks Adam!