VBscript and JScript

Discussion in 'ASP General' started by Christopher Brandsdal, Jan 22, 2004.

  1. Hi!

    Maby this is wring newsgroup..

    I'm using ASP / VBscript on my own cms system, but I needed to use some
    jscript to make something work... I'm new to jscript, so here is a simple
    question:

    (1) I want to count how many characters there is in a string. In ASP I just
    use <%=Len(Variabel)%> How do I do this in Jscript?

    (2) How can I display only a numer of characters from a variabel or a
    string? In ASP I use <%=Left(Variabel,20)%> How do I do this in Jscript?


    THe code i use is part vbscript and jscript. Hope somone can help me
    translate it to pure JScript :)


    var dot

    if(Len(oEventsList.GetBody()) > 20)
    {
    dot = "..."
    }

    Response.Write (Left(oEventsList.GetBody(),20) + dot + "<br><br>");


    Thanks in advance!

    Christopher Brandsdal
    Norway
     
    Christopher Brandsdal, Jan 22, 2004
    #1
    1. Advertising

  2. Christopher Brandsdal

    Ray at Guest

    "Christopher Brandsdal" <> wrote in message
    news:%...
    > Hi!
    >
    > Maby this is wring newsgroup..
    >
    > I'm using ASP / VBscript on my own cms system, but I needed to use some
    > jscript to make something work... I'm new to jscript, so here is a simple
    > question:
    >
    > (1) I want to count how many characters there is in a string. In ASP I

    just
    > use <%=Len(Variabel)%> How do I do this in Jscript?


    In jscript, strings are objects. You'd use the length property of the
    object as so:

    <%@ Language=JScript %>
    <%
    var x = "hi there."
    Response.write(x.length)
    %>


    >
    > (2) How can I display only a numer of characters from a variabel or a
    > string? In ASP I use <%=Left(Variabel,20)%> How do I do this in Jscript?


    <%
    var x = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
    Response.write(x.substr(1,20))
    %>


    You can download the WSH documentation (which includes the jscript
    documentation) here.
    http://www.microsoft.com/downloads/details.aspx?FamilyId=01592C48-207D-4BE1-8A76-1C4099D7BBB9

    Or view the string object info here.
    http://msdn.microsoft.com/library/en-us/script56/html/js56jsobjstring.asp

    I think Microsoft did a great job on their scripting documentation.

    Ray at work
     
    Ray at, Jan 22, 2004
    #2
    1. Advertising

  3. Christopher Brandsdal

    Ray at Guest

    You already had your answer from another group and were on your way with it
    when I took time out of my day to answer your questions for you. This is
    bothersome. Please do not multipost.

    Ray at work

    "Christopher Brandsdal" <> wrote in message
    news:%...
    > Hi!
    >
    > Maby this is wring newsgroup..
    >
    > I'm using ASP / VBscript on my own cms system, but I needed to use some
    > jscript to make something work... I'm new to jscript, so here is a simple
    > question:
    >
    > (1) I want to count how many characters there is in a string. In ASP I

    just
    > use <%=Len(Variabel)%> How do I do this in Jscript?
    >
    > (2) How can I display only a numer of characters from a variabel or a
    > string? In ASP I use <%=Left(Variabel,20)%> How do I do this in Jscript?
    >
    >
    > THe code i use is part vbscript and jscript. Hope somone can help me
    > translate it to pure JScript :)
    >
    >
    > var dot
    >
    > if(Len(oEventsList.GetBody()) > 20)
    > {
    > dot = "..."
    > }
    >
    > Response.Write (Left(oEventsList.GetBody(),20) + dot + "<br><br>");
    >
    >
    > Thanks in advance!
    >
    > Christopher Brandsdal
    > Norway
    >
    >
    >
     
    Ray at, Jan 22, 2004
    #3
  4. Sorry I will NEVER multipost again.
    But thank you for wanting helping me!

    "Ray at <%=sLocation%>" <myfirstname at lane34 dot com> skrev i melding
    news:OGAQ$...
    > You already had your answer from another group and were on your way with

    it
    > when I took time out of my day to answer your questions for you. This is
    > bothersome. Please do not multipost.
    >
    > Ray at work
    >
    > "Christopher Brandsdal" <> wrote in message
    > news:%...
    > > Hi!
    > >
    > > Maby this is wring newsgroup..
    > >
    > > I'm using ASP / VBscript on my own cms system, but I needed to use some
    > > jscript to make something work... I'm new to jscript, so here is a

    simple
    > > question:
    > >
    > > (1) I want to count how many characters there is in a string. In ASP I

    > just
    > > use <%=Len(Variabel)%> How do I do this in Jscript?
    > >
    > > (2) How can I display only a numer of characters from a variabel or a
    > > string? In ASP I use <%=Left(Variabel,20)%> How do I do this in Jscript?
    > >
    > >
    > > THe code i use is part vbscript and jscript. Hope somone can help me
    > > translate it to pure JScript :)
    > >
    > >
    > > var dot
    > >
    > > if(Len(oEventsList.GetBody()) > 20)
    > > {
    > > dot = "..."
    > > }
    > >
    > > Response.Write (Left(oEventsList.GetBody(),20) + dot + "<br><br>");
    > >
    > >
    > > Thanks in advance!
    > >
    > > Christopher Brandsdal
    > > Norway
    > >
    > >
    > >

    >
    >
     
    Christopher Brandsdal, Jan 22, 2004
    #4
    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,296
    Jon Maz
    Sep 9, 2004
  2. Maxwell2006
    Replies:
    5
    Views:
    2,426
    Steven Cheng[MSFT]
    Mar 7, 2006
  3. Christopher Brandsdal

    JScript and VBscript

    Christopher Brandsdal, Dec 18, 2003, in forum: ASP General
    Replies:
    24
    Views:
    311
    Roland Hall
    Dec 31, 2003
  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