Be nice

Discussion in 'ASP General' started by George Hester, Nov 2, 2003.

  1. George Hester, Nov 2, 2003
    #1
    1. Advertising

  2. 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" <> wrote in message
    news:#...
    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.aspx?scid=kb;en-us;253604&Product=asp

    --
    George Hester
    __________________________________
     
    Aaron Bertrand [MVP], Nov 2, 2003
    #2
    1. Advertising

  3. George Hester

    Evertjan. Guest

    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)
     
    Evertjan., Nov 2, 2003
    #3
  4. George Hester

    Bob Barrows Guest

    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.aspx?scid=kb;en-us;253604&Product=asp



    http://msdn.microsoft.com/library/en-us/script56/html/vsidxconcatenation.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"
     
    Bob Barrows, Nov 2, 2003
    #4
  5. > + 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?
     
    Aaron Bertrand [MVP], Nov 2, 2003
    #5
  6. George Hester

    Bob Barrows Guest

    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"
     
    Bob Barrows, Nov 3, 2003
    #6
  7. George Hester

    Ken Schaefer Guest

    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" <> wrote in message
    news:%...
    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.aspx?scid=kb;en-us;253604&Product=asp

    --
    George Hester
    __________________________________
     
    Ken Schaefer, Nov 3, 2003
    #7
  8. George Hester

    Joe Fawcett Guest

    "Ken Schaefer" <> wrote in message
    news:...
    > 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
     
    Joe Fawcett, Nov 3, 2003
    #8
  9. George Hester

    CJM Guest

    "Bob Barrows" <> wrote in message
    news:u$...
    > 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
     
    CJM, Nov 3, 2003
    #9
  10. George Hester

    Roland Hall Guest

    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" <> wrote in message
    news:...
    "Bob Barrows" <> wrote in message
    news:u$...
    > 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, Nov 4, 2003
    #10
  11. Dang all I know is that the sample didn't work with "+" and did with "&." Must be something else I did then to make it work for it didn't as written. Of course I hooked it up to my own DSN.

    --
    George Hester
    __________________________________
    "George Hester" <> wrote in message news:#...
    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.aspx?scid=kb;en-us;253604&Product=asp

    --
    George Hester
    __________________________________
     
    George Hester, Nov 6, 2003
    #11
  12. George Hester

    keyur shah Guest

    This sounds crazy... when did developers @ microsoft started mixing
    languages... which is even not permitted in .NET :)



    Keyur Shah
    Verizon Communications
    732-423-0745

    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
     
    keyur shah, Nov 6, 2003
    #12
  13. George Hester

    Bob Barrows Guest

    keyur shah wrote:
    > This sounds crazy... when did developers @ microsoft started mixing
    > languages... which is even not permitted in .NET :)


    Again: they didn't "+" is a perfectly good concatenation character in
    vbscript. I've already posted a link to the documentation in this thread.

    That said, I always use "&" for concatenation in vbscript. This habit really
    burns me when I'm writing jscript code ...

    Bob Barrows

    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.
     
    Bob Barrows, Nov 6, 2003
    #13
  14. George Hester

    Ray at Guest

    "Bob Barrows" <> wrote in message
    news:...

    >
    > Again: they didn't "+" is a perfectly good concatenation character in
    > vbscript. I've already posted a link to the documentation in this thread.
    >
    > That said, I always use "&" for concatenation in vbscript. This habit

    really
    > burns me when I'm writing jscript code ...


    Have you coded in php at all? That's the stupidest concatenator I've ever
    seen. . It goes against all my instincts, but that's just because I was
    raised in a Microsoft family, I guess.

    Ray at work
     
    Ray at, Nov 6, 2003
    #14
  15. George Hester

    Bob Barrows Guest

    Ray at <%=sLocation%> wrote:
    > "Bob Barrows" <> wrote in message
    > news:...
    >
    >>
    >> Again: they didn't "+" is a perfectly good concatenation character
    >> in vbscript. I've already posted a link to the documentation in this
    >> thread.
    >>
    >> That said, I always use "&" for concatenation in vbscript. This
    >> habit really burns me when I'm writing jscript code ...

    >
    > Have you coded in php at all?


    Nope.

    >That's the stupidest concatenator I've
    > ever seen. .


    Uuuum - what concatenator are you talking about?

    Bob

    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.
     
    Bob Barrows, Nov 6, 2003
    #15
  16. George Hester

    Ray at Guest

    "Bob Barrows" <> wrote in message
    news:...

    > > Have you coded in php at all?

    >
    > Nope.
    >
    > >That's the stupidest concatenator I've
    > > ever seen. .

    >
    > Uuuum - what concatenator are you talking about?


    ..

    $var1="Bob";
    $var2="Barrows";
    $var3=$var1." ".$var2;

    Ray at work
     
    Ray at, Nov 6, 2003
    #16
  17. > $var3=$var1." ".$var2;

    Yeah, that's sexy.

    Uh, wait, no it's not.
     
    Aaron Bertrand - MVP, Nov 6, 2003
    #17
  18. George Hester

    Bob Barrows Guest

    Ray at <%=sLocation%> wrote:
    > "Bob Barrows" <> wrote in message
    > news:...
    >
    >>> Have you coded in php at all?

    >>
    >> Nope.
    >>
    >>> That's the stupidest concatenator I've
    >>> ever seen. .

    >>
    >> Uuuum - what concatenator are you talking about?

    >
    > .
    >
    > $var1="Bob";
    > $var2="Barrows";
    > $var3=$var1." ".$var2;


    Ughhhh!

    Bob
    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.
     
    Bob Barrows, Nov 6, 2003
    #18
  19. George Hester

    Ray at Guest

    "William Tasso" <> wrote in message
    news:...

    >
    > exactly ;o)
    >
    > $var1="Bob";
    > $var2="Barrows";
    >
    > $var3 = $var1;
    > $var3 .= " ";
    > $var3 .= $var2;
    >
    > produces the same result


    This further exposes my mother tongue. I never think of the += type of
    things, even when I'm doing a set /a in a batch file. I suck.

    Ray at work
     
    Ray at, Nov 6, 2003
    #19
  20. Nope. No nulls.

    --
    George Hester
    __________________________________
    "Bob Barrows" <> wrote in message news:#...
    As previously noted in this thread, "+" and "&" handle Nulls differently. Is there a possibility that any of the fields in your recordset contain Null?

    Bob Barrows

    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From header is my spam trap, so I don't check it very often. You will get a quicker response by posting to the newsgroup.
    "George Hester" <> wrote in message news:...
    Response.Write iCnt + " <a href=""http://" + rs(1) + """ target=_new>" + rs(1) + "</a><BR>"


    Response.Write iCnt & " <a href=""http://" & rs(1) & """ target=_new>" & rs(1) & "</a><BR>"
    No problem.

    Note there are enough strings in here to show that coersion should not be an issue.

    --
    George Hester
    __________________________________
    "George Hester" <> wrote in message news:#...
    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.aspx?scid=kb;en-us;253604&Product=asp

    --
    George Hester
    __________________________________
     
    George Hester, Nov 8, 2003
    #20
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Hugh G. Johnson

    ASP.NET and SQL 2000 not playing nice?

    Hugh G. Johnson, Sep 6, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    526
    Hans Kesting
    Sep 7, 2004
  2. =?Utf-8?B?RG90bmV0IFdhbmRlcmVy?=

    I'm Envious of the nice ASP.NET gradient toolbars

    =?Utf-8?B?RG90bmV0IFdhbmRlcmVy?=, Nov 15, 2004, in forum: ASP .Net
    Replies:
    5
    Views:
    4,472
    Scott M.
    Nov 15, 2004
  3. SpamProof
    Replies:
    3
    Views:
    663
    SpamProof
    Dec 1, 2003
  4. Cram TeXeD

    [Jelly] A very nice tool but...

    Cram TeXeD, Dec 17, 2003, in forum: Java
    Replies:
    3
    Views:
    442
    Andrew Thompson
    Dec 17, 2003
  5. lounger
    Replies:
    14
    Views:
    719
    Christophe Vanfleteren
    Apr 16, 2004
Loading...

Share This Page