Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP General > Be nice

Reply
Thread Tools

Be nice

 
 
George Hester
Guest
Posts: n/a
 
      11-02-2003
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
__________________________________
 
Reply With Quote
 
 
 
 
Aaron Bertrand [MVP]
Guest
Posts: n/a
 
      11-02-2003
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" <(E-Mail Removed)> wrote in message
news:#(E-Mail Removed)...
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
__________________________________


 
Reply With Quote
 
 
 
 
Evertjan.
Guest
Posts: n/a
 
      11-02-2003
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)
 
Reply With Quote
 
Bob Barrows
Guest
Posts: n/a
 
      11-02-2003
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"


 
Reply With Quote
 
Aaron Bertrand [MVP]
Guest
Posts: n/a
 
      11-02-2003
> + 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?


 
Reply With Quote
 
Bob Barrows
Guest
Posts: n/a
 
      11-03-2003
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"


 
Reply With Quote
 
Ken Schaefer
Guest
Posts: n/a
 
      11-03-2003
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" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
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
__________________________________


 
Reply With Quote
 
Joe Fawcett
Guest
Posts: n/a
 
      11-03-2003
"Ken Schaefer" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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



 
Reply With Quote
 
CJM
Guest
Posts: n/a
 
      11-03-2003
"Bob Barrows" <(E-Mail Removed)> wrote in message
news:u$(E-Mail Removed)...
> 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


 
Reply With Quote
 
Roland Hall
Guest
Posts: n/a
 
      11-04-2003
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" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
"Bob Barrows" <(E-Mail Removed)> wrote in message
news:u$(E-Mail Removed)...
> 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



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
nice featurlette deerpark aka ff 1.6a Splibbilla Firefox 1 09-17-2005 06:31 AM
Very nice MMORPG (FREE) Silverstrand Gaming 7 08-14-2005 03:41 AM
Bookmarks not playing nice MEow Firefox 2 12-21-2004 04:48 PM
Nice PHP script Charles Firefox 6 06-23-2004 09:44 PM
Re: Nice PHP script Matt Firefox 1 06-23-2004 03:37 PM



Advertisments