discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Syntax error

R
rr156
Fri, Aug 12, 2022 9:51 AM

why can't this script be translated?

function BitAnd(Arg, Bit, n = 0, s = 0) =
  let(Max = floor(ln(Arg)/ln(2)), m = 2^n/, _x = echo(Max, m, n, s)/)
    n > Max ?
      s :
      BitAnd(Arg, Bit, n+1, s + m * (floor(Arg / m) % 2) * (floor(Bit /
m) % 2));

module Test(xx){
  echo(xx);
}

left = 1;
module One(yy){
  Test((BitAnd(yy, left) <> 0) ? 20: 30);
}

One(11);

Result: line 13 Parser error: syntax error

rr

why can't this script be translated? function BitAnd(Arg, Bit, n = 0, s = 0) =   let(Max = floor(ln(Arg)/ln(2)), m = 2^n/*, _x = echo(Max, m, n, s)*/)     n > Max ?       s :       BitAnd(Arg, Bit, n+1, s + m * (floor(Arg / m) % 2) * (floor(Bit / m) % 2)); module Test(xx){   echo(xx); } left = 1; module One(yy){   Test((BitAnd(yy, left) <> 0) ? 20: 30); } One(11); Result: line 13 Parser error: syntax error rr
TP
Torsten Paul
Fri, Aug 12, 2022 10:18 AM

On 12.08.22 11:51, rr156 wrote:

  Test((BitAnd(yy, left) <> 0) ? 20: 30);

There is no "<>" only "!=".

ciao,
Torsten.

On 12.08.22 11:51, rr156 wrote: >   Test((BitAnd(yy, left) <> 0) ? 20: 30); There is no "<>" only "!=". ciao, Torsten.
J
jon
Fri, Aug 12, 2022 12:50 PM

"<>" makes sense in many languages, but not in OpenSCAD. You need "!="

Jon

On 8/12/2022 5:51 AM, rr156 wrote:

function BitAnd(Arg, Bit, n = 0, s = 0) =
  let(Max = floor(ln(Arg)/ln(2)), m = 2^n/, _x = echo(Max, m, n, s)/)
    n > Max ?
      s :
      BitAnd(Arg, Bit, n+1, s + m * (floor(Arg / m) % 2) * (floor(Bit
/ m) % 2));

module Test(xx){
  echo(xx);
}

left = 1;
module One(yy){
  Test((BitAnd(yy, left) <> 0) ? 20: 30);
}

One(11);

"<>" makes sense in many languages, but not in OpenSCAD. You need "!=" Jon On 8/12/2022 5:51 AM, rr156 wrote: > function BitAnd(Arg, Bit, n = 0, s = 0) = >   let(Max = floor(ln(Arg)/ln(2)), m = 2^n/*, _x = echo(Max, m, n, s)*/) >     n > Max ? >       s : >       BitAnd(Arg, Bit, n+1, s + m * (floor(Arg / m) % 2) * (floor(Bit > / m) % 2)); > > module Test(xx){ >   echo(xx); > } > > left = 1; > module One(yy){ >   Test((BitAnd(yy, left) <> 0) ? 20: 30); > } > > One(11);