Translate from vbscript to javascript?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Martin

    Translate from vbscript to javascript?


    Shown below is the body of a web page I'm developing. When it loads, a
    socket connection is established back to a socket that's on my server.
    I can then send a message from the server and it will show up on this
    page. This works as intended (IE only, of course).

    I'm going to add some functionality to this script and I want to do it
    in javascript - I'd like to do this part in javascript also.

    Can someone tell me what I need to do to translate this?

    Thanks.


    <body>

    <object id='Winsock1' classid='clsid:---A_BUNCH_OF_NUMB ERS'
    codebase='/mywinsock.dll'> </object>

    <script language=vbscri pt>
    <!--
    Sub Window_OnLoad
    Winsock1.CloseC onnection
    Winsock1.Remote Host = Window.Location .Hostname
    Winsock1.Remote Port = 1234
    Winsock1.LocalP ort = 0
    Winsock1.Connec t
    End Sub

    Sub Window_OnUnload
    Winsock1.CloseC onnection
    End Sub

    Sub Winsock1_DataAr rival(bytesTota l)
    Dim Msg
    Winsock1.Getdat a Msg, vbString
    alert(Msg)
    End Sub

    -->
    </script>

    </body>

  • Martin

    #2
    Re: Translate from vbscript to javascript?

    Here's what I've tried so far - it doesn't work. (it's telling me
    there's a ";" missing in the "<body onload..." line)

    I've created a function named ConnectSocket that is called from the
    onload event to replace the Sub Window_Onload in the vbscript version.
    Similarly, I created the CloseSocket function (called from the
    onunload event) to replace the Window_OnUnload sub in the vbscript.

    The original Winsock1_DataAr rival sub was simply converted to a
    function - I have no idea what should actually be done with it.

    Can someone give me a clue here?

    Thanks.

    --------------------------------------------------------
    <body onload='Connect Socket();' onunload='Close Socket();'>

    <object id='Winsock1' classid='clsid:---A_BUNCH_OF_NUMB ERS---'
    codebase='/mywinsock.dll'> </object>

    <script type='text/javascript'>
    function ConnectSocket() {
    Winsock1.CloseC onnection;
    Winsock1.Remote Host = Window.Location .Hostname;
    Winsock1.Remote Port = 1234;
    Winsock1.LocalP ort = 0;
    Winsock1.Connec t;
    }

    function CloseSocket(){
    Winsock1.CloseC onnection;
    }

    function Winsock1_DataAr rival(bytesTota l){
    var Msg;
    Winsock1.Getdat a Msg;
    Msg = Mid(Msg,2);
    alert(Msg);
    }

    </script>
    --------------------------------------------------------

    On Wed, 17 Nov 2004 16:31:09 -0700, Martin <martinvalley@c omcast.net>
    wrote:
    [color=blue]
    >
    >Shown below is the body of a web page I'm developing. When it loads, a
    >socket connection is established back to a socket that's on my server.
    >I can then send a message from the server and it will show up on this
    >page. This works as intended (IE only, of course).
    >
    >I'm going to add some functionality to this script and I want to do it
    >in javascript - I'd like to do this part in javascript also.
    >
    >Can someone tell me what I need to do to translate this?
    >
    >Thanks.
    >
    >
    ><body>
    >
    ><object id='Winsock1' classid='clsid:---A_BUNCH_OF_NUMB ERS---'
    >codebase='/mywinsock.dll'> </object>
    >
    ><script language=vbscri pt>
    ><!--
    >Sub Window_OnLoad
    > Winsock1.CloseC onnection
    > Winsock1.Remote Host = Window.Location .Hostname
    > Winsock1.Remote Port = 1234
    > Winsock1.LocalP ort = 0
    > Winsock1.Connec t
    >End Sub
    >
    >Sub Window_OnUnload
    > Winsock1.CloseC onnection
    >End Sub
    >
    >Sub Winsock1_DataAr rival(bytesTota l)
    > Dim Msg
    > Winsock1.Getdat a Msg, vbString
    > alert(Msg)
    >End Sub
    >
    >-->
    ></script>
    >
    ></body>[/color]

    Comment

    Working...