JScript and VBscript

Discussion in 'ASP General' started by Christopher Brandsdal, Dec 18, 2003.

  1. If I have a .ASP page that runs JScript code - is it possible to include an
    ..ASP page that runs VBscript???
     
    Christopher Brandsdal, Dec 18, 2003
    #1
    1. Advertising

  2. Christopher Brandsdal

    Atrax Guest

    Atrax, Dec 18, 2003
    #2
    1. Advertising

  3. Thanks ;)

    "Atrax" <> skrev i melding
    news:...
    > no, you can't mix two languages the way you're asking.
    >
    >
    > you could convert one into a WSC and use that, or you could use <script
    > runat="server"> rather than ASP delimiters...
    >
    >
    >
    >
    >
    > ________________________________________
    > Atrax. MVP, IIS
    > http://rtfm.atrax.co.uk/
    >
    > newsflash : Atrax.Richedit 1.0 now released.
    > http://rtfm.atrax.co.uk/infinitemonkeys/components/Atrax.RichEdit/
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
    > Don't just participate in USENET...get rewarded for it!
     
    Christopher Brandsdal, Dec 18, 2003
    #3
  4. "Atrax" wrote:
    >
    > you could convert one into a WSC and use that, or you could use
    > <script runat="server"> rather than ASP delimiters...


    Server.Execute() is also available...


    --
    Dave Anderson

    Unsolicited commercial email will be read at a cost of $500 per message. Use
    of this email address implies consent to these terms. Please do not contact
    me directly or ask me to contact you directly for assistance. If your
    question is worth asking, it's worth posting.
     
    Dave Anderson, Dec 18, 2003
    #4
  5. Christopher Brandsdal

    Roland Hall Guest

    Be aware of the execution order:
    1.. Script in <SCRIPT> elements in nondefault languages
    2.. Inline script
    3.. Script in <SCRIPT> elements in the default language
    --
    Roland

    This information is distributed in the hope that it will be useful, but
    without any warranty; without even the implied warranty of merchantability
    or fitness for a particular purpose.
     
    Roland Hall, Dec 19, 2003
    #5
  6. "Roland Hall" wrote:
    >
    > Be aware of the execution order...


    Curiously enough, this can be "circumvented". A function (or Function or
    Sub) can be called from any block regardless of which one defines it -- and
    regardless of the "execution order".



    --
    Dave Anderson

    Unsolicited commercial email will be read at a cost of $500 per message. Use
    of this email address implies consent to these terms. Please do not contact
    me directly or ask me to contact you directly for assistance. If your
    question is worth asking, it's worth posting.
     
    Dave Anderson, Dec 19, 2003
    #6
  7. Christopher Brandsdal

    Guest Guest

    help & support, searching for information stored on this
    computor,recieving genetic failure.
    >-----Original Message-----
    >If I have a .ASP page that runs JScript code - is it

    possible to include an
    >..ASP page that runs VBscript???
    >
    >
    >.
    >
     
    Guest, Dec 19, 2003
    #7
  8. Christopher Brandsdal

    Guest Guest

    help & support,searching for information on this
    computor,recieving genetic failure
    >-----Original Message-----
    >If I have a .ASP page that runs JScript code - is it

    possible to include an
    >..ASP page that runs VBscript???
    >
    >
    >.
    >
     
    Guest, Dec 19, 2003
    #8
  9. Christopher Brandsdal

    Bob Barrows Guest

    wrote:
    > help & support, searching for information stored on this
    > computor,recieving genetic failure.


    Yes! It's obvious a mutation has occurred ...

    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, Dec 19, 2003
    #9
  10. Christopher Brandsdal

    Bob Barrows Guest

    wrote:
    > help & support,searching for information on this
    > computor,recieving genetic failure


    The mutation is spreading! Quick, someone call the CDC! ;-)
    --
    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, Dec 19, 2003
    #10
  11. "Mike Florio" wrote:
    >
    > Only limitation is that you can't pass a querystring to
    > Server.Execute().


    I'd say there are a few more. The calling script shares no variables or
    functions with the one being executed, for example.


    --
    Dave Anderson

    Unsolicited commercial email will be read at a cost of $500 per message. Use
    of this email address implies consent to these terms. Please do not contact
    me directly or ask me to contact you directly for assistance. If your
    question is worth asking, it's worth posting.
     
    Dave Anderson, Dec 19, 2003
    #11
  12. Christopher Brandsdal

    Roland Hall Guest

    "Dave Anderson" wrote:
    > "Roland Hall" wrote:
    > > Be aware of the execution order...

    >
    > Curiously enough, this can be "circumvented". A function (or Function or
    > Sub) can be called from any block regardless of which one defines it --

    and
    > regardless of the "execution order".


    Ok but wouldn't that require having knowledge of the order of execution?

    --
    Roland

    This information is distributed in the hope that it will be useful, but
    without any warranty; without even the implied warranty of merchantability
    or fitness for a particular purpose.
     
    Roland Hall, Dec 20, 2003
    #12
  13. Christopher Brandsdal

    Roland Hall Guest

    "Bob Barrows" wrote:
    > wrote:
    > > help & support, searching for information stored on this
    > > computor,recieving genetic failure.

    >
    > Yes! It's obvious a mutation has occurred ...


    You crack me up! (O:=
     
    Roland Hall, Dec 20, 2003
    #13
  14. Christopher Brandsdal

    Mark Schupp Guest

    > Ok but wouldn't that require having knowledge of the order of execution?

    No. Put the code in the different language into subroutines or functions
    (not inline). Then call those functions in the desired order from inline
    code in whichever language that you want to be "dominant".

    --
    Mark Schupp
    Head of Development
    Integrity eLearning
    www.ielearning.com


    "Roland Hall" <nobody@nowhere> wrote in message
    news:...
    > "Dave Anderson" wrote:
    > > "Roland Hall" wrote:
    > > > Be aware of the execution order...

    > >
    > > Curiously enough, this can be "circumvented". A function (or Function or
    > > Sub) can be called from any block regardless of which one defines it --

    > and
    > > regardless of the "execution order".

    >
    > Ok but wouldn't that require having knowledge of the order of execution?
    >
    > --
    > Roland
    >
    > This information is distributed in the hope that it will be useful, but
    > without any warranty; without even the implied warranty of merchantability
    > or fitness for a particular purpose.
    >
    >
    >
     
    Mark Schupp, Dec 22, 2003
    #14
  15. Christopher Brandsdal

    Roland Hall Guest

    "Mark Schupp" wrote:
    > > Ok but wouldn't that require having knowledge of the order of execution?

    >
    > No. Put the code in the different language into subroutines or functions
    > (not inline). Then call those functions in the desired order from inline
    > code in whichever language that you want to be "dominant".


    Correct. Without knowing the order of execution and not doing it as you
    suggested means you could get into trouble, which is my whole point!

    I prefer this answer: http://www.aspfaq.com/show.asp?id=2045 - It is better
    not to mix inline code with script blocks runat=server but should you have
    to, knowing the order of execution is better than not knowing.

    Mixed-language script blocks not in subs/functions. They get executed out
    of the order they were placed on the page.
    http://kiddanger.com/lab/langorder.asp

    <%@ Language=VBScript %>
    <% Option Explicit %>
    <script type="text/vbscript" language="vbscript" runat=server>
    Response.Write("one <br />")
    </script>
    <script type="text/javascript" language="javascript" runat=server>
    Response.Write("two <br />")
    </script>
    <%
    Response.Write("three <br />")
    %>
    <script type="text/javascript" language="javascript" runat=server>
    Response.Write("four <br />")
    </script>
    <script type="text/vbscript" language="vbscript" runat=server>
    Response.Write("five <br />")
    </script>

    Mixed-language script blocks in subs/functions called from inline script.
    They get executed in the order called from inline script.
    http://kiddanger.com/lab/langorder2.asp

    <%@ Language=VBScript %>
    <% Option Explicit %>
    <script type="text/vbscript" language="vbscript" runat=server>
    sub vb1()
    Response.Write("one <br />")
    end sub
    </script>
    <script type="text/javascript" language="javascript" runat=server>
    function js2() {
    Response.Write("two <br />")
    }
    </script>
    <%
    vb1
    js2
    Response.Write("three <br />")
    js4
    vb5
    %>
    <script type="text/javascript" language="javascript" runat=server>
    function js4() {
    Response.Write("four <br />")
    }
    </script>
    <script type="text/vbscript" language="vbscript" runat=server>
    sub vb5()
    Response.Write("five <br />")
    end sub
    </script>

    Ridiculous example:

    Default language VBScript, calling a JScript script block which calls a
    VBScript script inline function and writes the result from inline vbscript.
    If the ?n=# where # = a decimal number is not present, an error is called
    from vbscript inline script to a vbscript script block sub to display an
    error and syntax.

    http://kiddanger.com/lab/langorder3.asp
    http://kiddanger.com/lab/langorder3.asp?n=65535

    <%@ Language=VBScript %>
    <% Option Explicit %>
    <script type="text/jscript" language="jscript" runat=server>
    function jsHex(jsn) {
    return vbHex(jsn);
    }
    </script>
    <script type"text/vbscript" language="vbscript" runat=server>
    sub showError()
    Response.Write("<div style=""border: 1px solid black""><div
    style=""border-bottom: 1px solid black; padding-right: 2px;
    background-color: #ffe0e0""><span style=""color: white; background-color:
    red; border-right: 1px solid black"">Error!</span> Value expected.</div>" &
    vbCrLf & _
    "syntax: http://kiddanger.com/lab/langorder3.asp?n=" &
    server.HTMLEncode("<a decimal number>") & "<br />" & vbCrLf & _
    "Ex. http://kiddanger.com/lab/langorder3.asp?n=546</div>")
    end sub
    </script>
    <%
    function vbHex(vbn)
    vbHex = Hex(vbn)
    end function

    dim n
    n = Request.QueryString("n")
    if n = "" then
    showError
    else
    Response.Write("Decimal: " & n & " = Hex: " & jsHex(n) & "<br />")
    end if
    %>

    IMHO, not informing someone of the order of execution is ridiculous. That
    was my whole point. I know it's possible to make it work but not knowing
    could cause problems.

    --

    Roland

    This information is distributed in the hope that it will be useful, but
    without any warranty; without even the implied warranty of merchantability
    or fitness for a particular purpose.
     
    Roland Hall, Dec 23, 2003
    #15
  16. "Roland Hall" wrote:
    >>>
    >>> Ok but wouldn't that require having knowledge of the order of execution?

    >>
    >> No. Put the code in the different language into subroutines or functions
    >> (not inline). Then call those functions in the desired order from inline
    >> code in whichever language that you want to be "dominant".

    >
    > Correct. Without knowing the order of execution and not doing it as you
    > suggested means you could get into trouble, which is my whole point!


    And your point is wrong. If you follow Mark's advice, you CANNOT get in
    trouble, regardless of whether you know the order of execution or not.


    > ...IMHO, not informing someone of the order of execution is ridiculous.
    > That was my whole point.


    Which one was your whole point -- that it is ridiculous or that it could
    lead to trouble?


    > I know it's possible to make it work but not knowing could cause problems.


    Likewise with not knowing anything else about the technology you are working
    with. What's your point (whole or otherwise)?


    --
    Dave Anderson

    Unsolicited commercial email will be read at a cost of $500 per message. Use
    of this email address implies consent to these terms. Please do not contact
    me directly or ask me to contact you directly for assistance. If your
    question is worth asking, it's worth posting.
     
    Dave Anderson, Dec 27, 2003
    #16
  17. Christopher Brandsdal

    Roland Hall Guest

    "Dave Anderson" wrote:
    > And your point is wrong. If you follow Mark's advice, you CANNOT get in
    > trouble, regardless of whether you know the order of execution or not.


    If you do not know there is an execution order and you DO NOT put all
    non-default language script in subroutines called from inline script then
    you can get in trouble. How difficult is that for you to understand? Mark
    obviously knows about the execution order and thus uses this coding
    methodology. Where is the crime in letting others know WHY you should try
    to do it the way Mark suggested? I know you prefer the "Dave Anderson, Just
    Follow Me Blindly Method" but where is the education in that? Your
    methodology doesn't work.

    301 Error.
    Dave's Response: Problem with your keyboard, go into the BIOS setup and
    disable checking for the keyboard. You'll never experience this error
    again. Don't ask questions. This is a need to know basis and I don't think
    you need to know. You'll never need to know why if you just do as I say.

    User replaces keyboard and still experiences same error. Perhaps it's not
    plugged in? Educating the user in this case might be beneficial?! Perhaps
    the color-coded ps/2 ports, the mouse and keyboard are plugged into, might
    be reversed?! Or maybe the user's keyboard is wireless and the batteries
    are dead?!

    Educating someone as to WHY something should try to be done a certain way to
    avoid possible errors is a good thing. Not educating someone as to WHY and
    the possible errors that could occur is just plain dumb. If Aaron has a FAQ
    re: this issue, perhaps there are a lot of people that need some education
    regarding issues with the execution order of mixed-language server-side
    script blocks with inline script and how to avoid them?!

    --
    Roland

    This information is distributed in the hope that it will be useful, but
    without any warranty; without even the implied warranty of merchantability
    or fitness for a particular purpose.
     
    Roland Hall, Dec 28, 2003
    #17
  18. "Roland Hall" wrote:
    >
    > If you do not know there is an execution order and you DO NOT
    > put all non-default language script in subroutines called from
    > inline script then you can get in trouble.


    Define trouble.

    I think anyone with rudimentary troubleshooting skills can mix languages in
    ASP without "getting in trouble". I would further suggest that someone
    willing to use two languages is already savvy enough to explore the inherent
    issues to a point of reasonable understanding.

    But more to the point, order of execution is just SOMETHING TO KNOW about
    ASP. If you create an instance of something with VBScript and don't know
    that you're supposed to later set the variable reference to Nothing, you can
    get in trouble. If you put objects into session or application variables,
    you can get in trouble, whether you know it or not. If you don't understand
    the difference between an object and its default property, you can get in
    trouble.

    BFD. Mixing scripting languages doesn't have to be intuitive, it merely
    should be documented. And it is:
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnvid/html/msdn_vbnjscrpt.asp


    [Incoherent "Dave Anderson, Just Follow Me Blindly Method" rant snipped]

    > If Aaron has a FAQ re: this issue, perhaps there are a lot of
    > people that need some education regarding issues with the
    > execution order of mixed-language server-side script blocks
    > with inline script and how to avoid them?!


    My point is that people should understand the technology they are using, and
    the existence of the FAQ is not inconsistent with that or anything else I
    have said in this thread.


    --
    Dave Anderson

    Unsolicited commercial email will be read at a cost of $500 per message. Use
    of this email address implies consent to these terms. Please do not contact
    me directly or ask me to contact you directly for assistance. If your
    question is worth asking, it's worth posting.
     
    Dave Anderson, Dec 29, 2003
    #18
  19. Christopher Brandsdal

    Roland Hall Guest

    "Dave Anderson" wrote:
    > "Roland Hall" wrote:
    > >
    > > If you do not know there is an execution order and you DO NOT
    > > put all non-default language script in subroutines called from
    > > inline script then you can get in trouble.

    >
    > Define trouble.

    Code not executing in the order you wanted it to?

    > I think anyone with rudimentary troubleshooting skills can mix languages

    in
    > ASP without "getting in trouble". I would further suggest that someone
    > willing to use two languages is already savvy enough to explore the

    inherent
    > issues to a point of reasonable understanding.

    One does not define the other however, you did say 'suggest.' Using two
    languages does not prove you know them. Also, knowing the two languages, in
    this case JScript/Javascript and VBScript does not mean you understand the
    order of execution of the ASP processor.

    > But more to the point, order of execution is just SOMETHING TO KNOW about
    > ASP.

    That's all I have been saying. It is better to know than not know. From
    now on, I'm drawing pictures. (O:=

    > If you create an instance of something with VBScript and don't know
    > that you're supposed to later set the variable reference to Nothing, you

    can
    > get in trouble.

    Define trouble. (O:=
    The same is true if you don't wear a condom.

    > If you put objects into session or application variables,
    > you can get in trouble,

    Define trouble. (O:=
    The same is true if you don't call her the next day.

    > whether you know it or not.

    n/a

    > If you don't understand
    > the difference between an object and its default property, you can get in
    > trouble.

    Define trouble. (O:=
    The same is true if you don't know the difference between your *ss and a
    hole in the ground.

    > BFD.

    It could be.

    > Mixing scripting languages doesn't have to be intuitive, it merely
    > should be documented.

    The Bible has been around for many years but how many cannot recite the 10
    commandments?
    There is a lot of documentation out there you and I have not read. Just
    because it is documented doesn't mean it is known by the person trying to
    implement it. None of my ASP books actually reference the execution order,
    AFAIK. I read a post in here long ago and found out that way. I don't use
    runat=server so I have never experienced this issue but it was by chance,
    not by knowledge, even though it has been documented since 1998.

    > And it is:
    >

    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnvid/html/msdn_vbnjscrpt.asp
    Perhaps Microsoft thought it was necessary for people to KNOW?!

    > My point is that people should understand the technology they are using,

    I agree but you cannot know everything. This NG demonstrates that even the
    most seasoned developer sometimes has to ask for help.

    > and
    > the existence of the FAQ is not inconsistent with that or anything else I
    > have said in this thread.

    It's not just a river in Egypt anymore. (O:=

    --
    Roland

    This information is distributed in the hope that it will be useful, but
    without any warranty; without even the implied warranty of merchantability
    or fitness for a particular purpose.

    -Technet Script Center-
    http://www.microsoft.com/technet/treeview/default.asp?url=/technet/scriptcenter/default.asp
    -MSDN Library-
    http://msdn.microsoft.com/library/default.asp
     
    Roland Hall, Dec 29, 2003
    #19
  20. "Roland Hall" "wrote":
    >
    > This doesn't work - mismatch error
    >
    > [client-side example]


    That's irrelevant. This is an ASP forum, and the discussion has focused on
    the behavior of asp.dll, not on that of a client-side browser. I note that
    your code generates no errors for the following browsers (vacuously, of
    course):

    Mozilla/5.0 (Windows; U; Windows NT 5.2; en-US; rv:1.5) Gecko/20031007
    Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2) Opera 7.11 [en]

    In any case, it's unreasonable to assume you know the implemetation of
    scripting support for every version of every browser. We *do* know and have
    reasonable expectation of continued support for the behavior of asp.dll, and
    that is the only thing that matters in here.


    > Change the order of the script blocks and it works:


    Same fallacy...

    > It's modified a bit but not much. It's from some documentation
    > from Microsoft. It must be unreliable.


    Cute. You quote an article titled "Using VBScript and JScript on a Web
    Page", which specifically warns that this example ill not work. Rather than
    show mixed scripting behavior to be "unreliable", you provide the evidence
    that the documentation is correct for both the asp.dll behavior and for
    Internet Explorer's client-side behavior.

    Offering evidence that your argument is wrong is perhaps not the textbook
    way of persuading people, but it *does* have the attraction of novelty.



    --
    Dave Anderson

    Unsolicited commercial email will be read at a cost of $500 per message. Use
    of this email address implies consent to these terms. Please do not contact
    me directly or ask me to contact you directly for assistance. If your
    question is worth asking, it's worth posting.
     
    Dave Anderson, Dec 30, 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. Jon Maz
    Replies:
    4
    Views:
    1,298
    Jon Maz
    Sep 9, 2004
  2. Maxwell2006
    Replies:
    5
    Views:
    2,426
    Steven Cheng[MSFT]
    Mar 7, 2006
  3. Christopher Brandsdal

    VBscript and JScript

    Christopher Brandsdal, Jan 22, 2004, in forum: ASP General
    Replies:
    3
    Views:
    156
    Christopher Brandsdal
    Jan 22, 2004
  4. Serge Myrand

    VBScript and JScript

    Serge Myrand, Jul 14, 2004, in forum: ASP General
    Replies:
    3
    Views:
    128
    Aaron [SQL Server MVP]
    Jul 14, 2004
  5. Eugene Anthony

    window - jscript and vbscript

    Eugene Anthony, Jun 20, 2006, in forum: ASP General
    Replies:
    3
    Views:
    208
    Eugene Anthony
    Jun 21, 2006
Loading...

Share This Page