Re: php, phpBB3, MySQL, JavaScript, BBCode

<html>
<body>
<div id="div00">
<input type="button" onclick="addLine()" value="Gimme more"></input>
<input type="button" onclick="addColumn()" value="Give it out"></input>
<input type="button" onclick="run()" value="Run"></input>
<input type="button" onclick="takeover()" value="Take"></input>
<input type="text" id="run001"></input>
<br>
<script>
  let i = 0;
  let x = 6;
  let y = 12;
  let a;
  let values;

  function valuearrayinit () {
    var k, l;

    values = new Array (y);
    for (k = 0;  k < y;  k++)
        values [k] = new Array (x);
    i = x*y;
  }
  function valuearrayaddy () {
    y = y+1;
    values.length = y;
    values [length-1] = new Array (x);
    i = x*y;
  }
  function valuearrayaddx () {
    var k;
    x = x+1;
    for (k = 0;  k < y;  k++)
      values [k].length = x;
    i = x*y;
  }

  function valuearrayout () {
    i = 0;
    var k, l;
    a = new Array (x*y);
    for (k = 0;  k < y;  k++) {
      for (l = 0;  l < x;  l++) {
        a [i] = document.createElement ("input");
        a [i].type = "text";
        a [i].id = i.toString ();
        a [i].value = values [k][l];

        document.getElementById ("div00").appendChild (a [i]);

        i++;

        a.length = i;
      }


      p01 = document.createElement ("br");
      //p01.innerText = "";
      document.getElementById ("div00").appendChild (p01);
    }
  }


  function sum (x, y) {
    return x+y;
  }
  function sumx (y, beginx, endx) {
    var k;
    var sum = 0;
    for (k = beginx;  k < endx;  k++)
      sum = sum + values [y][k];
    return sum;
  }
  function sumy (ybegin, yend, x) {
    var k;
    var sum = 0;
    for (k = beginy;  k < endy;  k++)
      sum = sum + values [k][x];
    return sum;
  }

  function valuesinit () {
    var k, l;

    for (k = 0;  k < y;  k++) {
      for (l = 0;  l < x;  l++) {
        values [k][l] = k*x+l;
      }
    }
  }

  function takeover () {
    var k, l;
    var v;
    var j;
    for (j = 0, k = 0;  (k < y) \&amp;\&amp; (j < i);  k++) {
      for (l = 0;  (l < x) \&amp;\&amp; (j < i);  l++) {
        v = parseInt(a [j].value);
        values [k][l] = v;
        j++;
      }
    }
  }


  valuearrayinit ();
  valuesinit ();
  valuearrayout ();
  takeover ();

  let lexi;
  let lexp;

  function parserelementarsumme (cells) {
    var k, l;
    var columnbegin;
    var columnend;
    var linebegin;
    var linenend;
    var tmp;
    var sum;

    takeover ();

    columnbegin = cells.charCodeAt (0) - "A".charCodeAt (0);
    linebegin = parseInt(cells.slice (1,3));
    if (cells [3] != ':')
      alert ("error");
    columnend = cells.charCodeAt (4) - "A".charCodeAt (0);
    lineend = parseInt(cells.slice (5,7));

    if (columnend < columnbegin) {
      tmp = columnend;
      columnend = columnbegin;
      columnbegin = tmp;
    }

    if (lineend < linebegin) {
      tmp = lineend;
      lineend = linebegin;
      linbegin = tmp;
    }

    var sum = 0;
    for (k = columnbegin;  k <= columnend;  k++) {
      for (l = linebegin;  l <= lineend;  l++) {
        sum = sum + values [k][l];
      }

    }
    return sum;
  }

  function run () {
    //parserelementarsumme ("");
    lexi = 0;
    lexp = document.getElementById ("run001").value;
    lexp = "SUMME(SUMME(A01:B03;A01:B03);SUMME(C02:A01;A01:B03))";

    alert(sum (0));
  }

  function sum (sm) {
    if (lexp.slice(lexi+0,lexi+6).localeCompare("SUMME(") == 0) {
      lexi += 6;
      sm += sum (sm);
      if (lexp.slice (lexi,lexi+1).localeCompare (";") != 0)
        alert ("Error");
      lexi = lexi+1;
      sm += sum (sm);
      if (lexp.slice (lexi, lexi+1).localeCompare (")") != 0)
        alert ("Error");
      lexi = lexi+1;
    }
    else {
      sm = parserelementarsumme (lexp.slice(lexi,lexi+7));
      lexi = lexi+7;
    }
    return sm;
  }

  run ();
/*
ELEMENTARSUMME=(SpaltenindexZeilendex:Spaltenindex:Zeilenindex)
=SUMME(ELEMENTARSUMME;SUMME);

*/

</script>
</div>
</body>
</html>

Es macht Ausdrücke, wie dieses

SUMME(SUMME(A01:B03;A01:B03);SUMME(C02:A01;A01:B03))