Is it the script, filter program or version of explorer?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • the ram arm

    #1

    Is it the script, filter program or version of explorer?

    Can't seem to be able to run this array.

    <HTML>
    <HEAD></HEAD>
    <BODY>
    <script language="javas cript">
    function e(#####,n) {
    this.s = s;
    this.m = m;
    this.n = n;
    }

    var table = new Array();
    var i = 0;
    table[i] = new e("a", "A", 1);
    table[++i] = new e("b", "B", 2);
    etc...

    function let(l) {
    for (i = 0; i < 109; ++i) {
    if (l = table[i].number)
    return table[i].s + " "
    }
    return l+" "
    }

    function go() {
    s = new String("L")
    r = ''
    for (i = 0; i < s.length; ++i) {
    r += let(String.from CharCode(s.char At(i)))
    s += s.charAt(i)
    }
    document.write( r)
    }
    go()
    </script>

    </BODY>
    </HTML>

  • Lee

    #2
    Re: Is it the script, filter program or version of explorer?

    the ram arm said:[color=blue]
    >
    >Can't seem to be able to run this array.
    >
    ><HTML>
    ><HEAD></HEAD>
    ><BODY>
    ><script language="javas cript">
    >function e(#####,n) {
    > this.s = s;
    > this.m = m;
    > this.n = n;
    > }
    >
    >var table = new Array();
    >var i = 0;
    >table[i] = new e("a", "A", 1);
    >table[++i] = new e("b", "B", 2);
    >etc...
    >
    >function let(l) {
    > for (i = 0; i < 109; ++i) {
    > if (l = table[i].number)
    > return table[i].s + " "
    > }
    > return l+" "
    > }[/color]


    function e(#####,n) {

    should probably be:

    function e(s,m,n) {

    and:

    if (l = table[i].number)

    should probably be:

    if (l == table[i].n)

    since it looks like you're trying to make a comparison ( == instead of = )
    and you haven't defined an attribute named "number".

    If the numbers in your objects are all unique, you could simplify your
    code quite a bit:


    var table = new Array();

    function e(s,m,n) {
    this.s = s;
    this.m = m;
    table[n]=this;
    }

    Comment

    • Lasse Reichstein Nielsen

      #3
      Re: Is it the script, filter program or version of explorer?

      "the ram arm" <theramarm@yaho o.com> writes:
      [color=blue]
      > Can't seem to be able to run this array.[/color]

      How do you run an array?
      [color=blue]
      > <HTML>
      > <HEAD></HEAD>
      > <BODY>
      > <script language="javas cript">[/color]

      Should be
      <script type="text/javascript">
      [color=blue]
      > function e(#####,n) {[/color]

      I assume "#####" should be "s,m". Are you affected by some kind
      of moronic content filter? :)
      [color=blue]
      > this.s = s;
      > this.m = m;
      > this.n = n;
      > }
      >
      > var table = new Array();
      > var i = 0;
      > table[i] = new e("a", "A", 1);
      > table[++i] = new e("b", "B", 2);[/color]

      A shorter notation would be:

      var table = [
      new e("a", "A", 1),
      new e("b", "B", 2),
      // etc
      ];

      [color=blue]
      > function let(l) {
      > for (i = 0; i < 109; ++i) {[/color]

      Here I would make "i" a local variable:
      for (var i = 0; i < 109; i++) {

      I assume that 109 is the length of "table".
      [color=blue]
      > if (l = table[i].number)[/color]

      Should probably be:
      if (l == table[i].n)

      Notice the double equal, which is comparison, where the single
      is assigment. Also, e-objects have no "number" property, so
      I'm guessing it's the "n" property.
      [color=blue]
      > function go() {
      > s = new String("L")
      > r = ''
      > for (i = 0; i < s.length; ++i) {
      > r += let(String.from CharCode(s.char At(i)))[/color]

      What is happening here?

      S.charAt(i) is "L". Then String.fromChar Code("L") should fail.
      Do you mean:
      r += let(s.charCodeA t(i));
      That would make the argument to "let" a number. Probably not the
      correct number, since "L" has char code 76.
      [color=blue]
      > s += s.charAt(i)[/color]

      So s becomes "LL", then "LLL", then "LLLL", and the loop never ends.

      So, what are you trying to do? Because the code is far from being obvious,
      except where it is obviously wrong :)

      /L
      --
      Lasse Reichstein Nielsen - lrn@hotpop.com
      DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleD OM.html>
      'Faith without judgement merely degrades the spirit divine.'

      Comment

      Working...