Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   ASP General (http://www.velocityreviews.com/forums/f65-asp-general.html)
-   -   Be nice (http://www.velocityreviews.com/forums/t791362-be-nice.html)

George Hester 11-02-2003 09:28 PM

Be nice
 
It may help if someone at Microsoft knows how to write VBScript. Since when was "+" a string concatenation character in VBScript?

http://support.microsoft.com/default...04&Product=asp

--
George Hester
__________________________________

Aaron Bertrand [MVP] 11-02-2003 10:05 PM

Re: Be nice
 
Thanks George, I've forwarded the issue along to some folks (when I reviewed
the article, I found 6 or 7 other things I didn't like).





"George Hester" <hesterloli@hotmail.com> wrote in message
news:#LxHEhYoDHA.2772@TK2MSFTNGP10.phx.gbl...
It may help if someone at Microsoft knows how to write VBScript. Since when
was "+" a string concatenation character in VBScript?

http://support.microsoft.com/default...04&Product=asp

--
George Hester
__________________________________



Evertjan. 11-02-2003 10:52 PM

Re: Be nice
 
George Hester wrote on 02 nov 2003 in
microsoft.public.inetserver.asp.general:

> It may help if someone at Microsoft knows how to write VBScript.
> Since when was "+" a string concatenation character in VBScript?


"+" always was a string concatenation operator in VBScript
and in most earlier Basixc dialects.

The "&" as an more specific alternative is a latecomer in Basic.

Stopping the "+" operator having this behavour and reserving it for
numerical adding and optional unary operator behavour, would be a good
thing, IMHO.


--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

Bob Barrows 11-02-2003 10:52 PM

Re: Be nice
 
George Hester wrote:
> It may help if someone at Microsoft knows how to write VBScript.
> Since when was "+" a string concatenation character in VBScript?
>
> http://support.microsoft.com/default...04&Product=asp



http://msdn.microsoft.com/library/en...catenation.asp

+ is both a concatenation and an addition operator. The only difference in
vbscript between + and & is that & will force concatenation. If both
operands can be coerced to numbers, addition will occur. If either operand
cannot be coerced to numeric, concatenation will occur. When & is used,
concatenation is the only operation allowed, which means that both operands
are coerced to strings before the operation is done. This is
well-documented.

Bob Barrows

--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"



Aaron Bertrand [MVP] 11-02-2003 11:24 PM

Re: Be nice
 
> + is both a concatenation and an addition operator. The only difference in
> vbscript between + and & is that & will force concatenation. If both
> operands can be coerced to numbers, addition will occur. If either operand
> cannot be coerced to numeric, concatenation will occur. When & is used,
> concatenation is the only operation allowed, which means that both

operands
> are coerced to strings before the operation is done. This is
> well-documented.


I don't think George is trying to state that this isn't well-documented. I
think he is just implying (and I tend to agree) that the default
recommendation for string operations be + ... I think they should be using &
in all cases where they are not intending to perform an addition operation
(and I think it's poor that this dual construct was ever there in the first
place). Just because you *can* do something, and that it *is* well
documented, doesn't mean it's the way you *should* do it...

Now, of course, you could argue from the other side, e.g. that the +
operator has multiple functions in other languages, such as T-SQL, JScript,
C#, etc. But when an alternative that is better defined is there, why not
use it instead?



Bob Barrows 11-03-2003 12:55 AM

Re: Be nice
 
Aaron Bertrand [MVP] wrote:

> I don't think George is trying to state that this isn't
> well-documented. I think he is just implying (and I tend to agree)
> that the default recommendation for string operations be +


:-)
No, that is your interpretation of what George was saying. I think "It may
help if someone at Microsoft knows how to write VBScript." is a pretty clear
statement. And a very incorrect statement in this case. :-)

Bob Barrows
--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"



Ken Schaefer 11-03-2003 04:54 AM

Re: Be nice
 
Apparently since version 1 of VBScript according to my WSH Help file.

Well, it seems to be an overloaded operator that does different things
depending what you use it on.

Cheers
Ken

"George Hester" <hesterloli@hotmail.com> wrote in message
news:%23LxHEhYoDHA.2772@TK2MSFTNGP10.phx.gbl...
It may help if someone at Microsoft knows how to write VBScript. Since when
was "+" a string concatenation character in VBScript?

http://support.microsoft.com/default...04&Product=asp

--
George Hester
__________________________________



Joe Fawcett 11-03-2003 09:56 AM

Re: Be nice
 
"Ken Schaefer" <kenREMOVE@THISadOpenStatic.com> wrote in message
news:OAkeLacoDHA.1072@TK2MSFTNGP09.phx.gbl...
> Apparently since version 1 of VBScript according to my WSH Help file.
>
> Well, it seems to be an overloaded operator that does different things
> depending what you use it on.
>
> Cheers
> Ken
>

There's also this behaviour:

Dim sPlus, sAmpersand
sPlus = "Hello " + Null
sAmpersand = "Hello " & Null
WScript.echo sPlus & ""
WScript.echo sAmpersand & ""

Addition sign and Null gives Null, ampersand and Null treats Null as empty
string.

--

Joe




CJM 11-03-2003 12:13 PM

Re: Be nice
 
"Bob Barrows" <reb01501@NOyahoo.SPAMcom> wrote in message
news:u$VVoVaoDHA.372@TK2MSFTNGP11.phx.gbl...
> Aaron Bertrand [MVP] wrote:
>
> > I don't think George is trying to state that this isn't
> > well-documented. I think he is just implying (and I tend to agree)
> > that the default recommendation for string operations be +

>
> :-)
> No, that is your interpretation of what George was saying. I think "It may
> help if someone at Microsoft knows how to write VBScript." is a pretty

clear
> statement. And a very incorrect statement in this case. :-)


Actually, I agree with you both.

I agree George said what Bob said, but I think George meant what Aaron said
he meant...! George...??

Personally agree with Aaron. And Bob.

....er, I think.

Yes '+' is overloaded, and thus can be used fairly in this example. But
surely '&' would be the better default choice.

Chris



Roland Hall 11-04-2003 10:17 AM

Re: Be nice
 
It's overloaded and confusing.

<%@ Language=VBScript %>
<%
Option Explicit
dim an, a, eq, e, plus
an = "&" + "&"
a = "&"
eq = "=" & "="
e = "="
plus = "+"
%>
<script type="text/vbscript">
sub alertit(a, b)
msgbox "" & a + "<%=eq%>" + b & "<%=e%>TRUE", 64, "TRUE"
end sub
</script>
<script type="text/javascript">
var a<%=e%>"<%=a%>" <%=plus%> "<%=a%>", b<%=e%>"<%=an%>";
if(a <%=eq%> '&&' <%=an%> b <%=eq%> '&&') {
alert("a" <%=plus%> "<%=eq%>" <%=plus%> "b" <%=plus%> "<%=e%>" <%=plus%>
"TRUE");
alertit(a, b);
}
</script>

"CJM" <cjmwork@yahoo.co.uk> wrote in message
news:eqj6sNgoDHA.2488@TK2MSFTNGP12.phx.gbl...
"Bob Barrows" <reb01501@NOyahoo.SPAMcom> wrote in message
news:u$VVoVaoDHA.372@TK2MSFTNGP11.phx.gbl...
> Aaron Bertrand [MVP] wrote:
>
> > I don't think George is trying to state that this isn't
> > well-documented. I think he is just implying (and I tend to agree)
> > that the default recommendation for string operations be +

>
> :-)
> No, that is your interpretation of what George was saying. I think "It may
> help if someone at Microsoft knows how to write VBScript." is a pretty

clear
> statement. And a very incorrect statement in this case. :-)


Actually, I agree with you both.

I agree George said what Bob said, but I think George meant what Aaron said
he meant...! George...??

Personally agree with Aaron. And Bob.

....er, I think.

Yes '+' is overloaded, and thus can be used fairly in this example. But
surely '&' would be the better default choice.

Chris





All times are GMT. The time now is 08:10 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.