discuss@lists.openscad.org

OpenSCAD general discussion Mailing-list

View all threads

Re: parser error: syntax error....but cannot find it!

WH
Will Hardiman
Tue, Apr 5, 2022 8:39 AM

This may not fix the problem, but some things I have noticed that I am
uncertain of:

Your function socketsetscrewsizes doesn't appear to be terminated with a
semicolon.

You seem to use size as a variable in the second half of the code (e.g. pd
= pointdiameter(size);) but I can't see where it is assigned.

You have a variable called pointdiameter, and a function called
pointdiameter. Does openscad allow this?

The vector for size==16 has 4 elements ( probably a comma in place of a
decimal point).

In my experience, openscad is not very good at telling you where the error
actually comes from, so perhaps any one of these could be causing it. Or
not.

Cheers,
Will

On Tue, 5 Apr 2022, 09:27 3dcase via Discuss, discuss@lists.openscad.org
wrote:

---------- Forwarded message ----------
From: 3dcase 3dcase@protonmail.com
To: "discuss@lists.openscad.org" discuss@lists.openscad.org
Cc:
Bcc:
Date: Tue, 05 Apr 2022 08:26:26 +0000
Subject: [OpenSCAD] parser error: syntax error....but cannot find it!
Hello at the Openscad forum,

trying my first code with a lookup function from a list, and I get a
parser error: syntax error. The problem is that I cannot find what it wants
from me. I copied an existing syntax, but I must be missing something
because that works and mine does not.

A hint with a little explanation would be really appreciated.

$fn=60;
//flat point set screw is according ISO 4026
//cone point set screw is according ISO 4027
//cup point set screw is according ISO 4029
//example
//iso_4026(size=1.6, length=3);
pointdiameter=0;
socket=1;
pitch=2;
//size==X ? [pointdiameter, socket, pitch]:
function socketsetscrewsizes(size)=
size==1.6 ? [0.8 , 0.78 , 0.35]:
size==2 ? [1 , 0.98 , 0.4]:
size==2.5 ? [1.5 , 1.4 , 0.45]:
size==3 ? [2 , 1.66 , 0.5]:
size==4 ? [2.5 , 2.23 , 0.7]:
size==5 ? [3.5 , 2.8 , 0.8]:
size==6 ? [4 , 3.36 , 1]:
size==8 ? [5.5 , 4.5 , 1.25]:
size==10 ? [7 , 5.66 , 1.5]:
size==12 ? [8.5 , 6.8 , 1.75]:
size==16 ? [12 , 9,1 , 2]:
size==20 ? [15 , 11.44 , 2.5]:
size==24 ? [18 , 13.6 , 3]:
((this below is the line with the error. It puts it at the first bracket
before "size"))
function pointdiameter(size) = socketsetscrewsizes(size)[ pointdiameter];
function socket(size) = socketsetscrewsizes(size)[ socket];
function pitch(size) = socketsetscrewsizes(size)[ pitch];

pd = pointdiameter(size);
s = socket(size);
pitch = pitch(size);
l = length;
offset = (size-pd)/2;
module iso_4026(size , length) {
difference() {
hull() {
cylinder(h=l,d=pd);
translate([0,0,pitch])cylinder(h=l-pitch-offset,d=size)
}
cylinder(h=size*s, d=s, $fn=6,center=true);
}

}

Sent with ProtonMail https://protonmail.com/ secure email.

---------- Forwarded message ----------
From: 3dcase via Discuss discuss@lists.openscad.org
To: "discuss@lists.openscad.org" discuss@lists.openscad.org
Cc: 3dcase 3dcase@protonmail.com
Bcc:
Date: Tue, 05 Apr 2022 08:26:26 +0000
Subject: [OpenSCAD] parser error: syntax error....but cannot find it!


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

This may not fix the problem, but some things I have noticed that I am uncertain of: Your function socketsetscrewsizes doesn't appear to be terminated with a semicolon. You seem to use size as a variable in the second half of the code (e.g. pd = pointdiameter(size);) but I can't see where it is assigned. You have a variable called pointdiameter, and a function called pointdiameter. Does openscad allow this? The vector for size==16 has 4 elements ( probably a comma in place of a decimal point). In my experience, openscad is not very good at telling you where the error actually comes from, so perhaps any one of these could be causing it. Or not. Cheers, Will On Tue, 5 Apr 2022, 09:27 3dcase via Discuss, <discuss@lists.openscad.org> wrote: > > > > ---------- Forwarded message ---------- > From: 3dcase <3dcase@protonmail.com> > To: "discuss@lists.openscad.org" <discuss@lists.openscad.org> > Cc: > Bcc: > Date: Tue, 05 Apr 2022 08:26:26 +0000 > Subject: [OpenSCAD] parser error: syntax error....but cannot find it! > Hello at the Openscad forum, > > trying my first code with a lookup function from a list, and I get a > parser error: syntax error. The problem is that I cannot find what it wants > from me. I copied an existing syntax, but I must be missing something > because that works and mine does not. > > A hint with a little explanation would be really appreciated. > > > $fn=60; > //flat point set screw is according ISO 4026 > //cone point set screw is according ISO 4027 > //cup point set screw is according ISO 4029 > //example > //iso_4026(size=1.6, length=3); > pointdiameter=0; > socket=1; > pitch=2; > //size==X ? [pointdiameter, socket, pitch]: > function socketsetscrewsizes(size)= > size==1.6 ? [0.8 , 0.78 , 0.35]: > size==2 ? [1 , 0.98 , 0.4]: > size==2.5 ? [1.5 , 1.4 , 0.45]: > size==3 ? [2 , 1.66 , 0.5]: > size==4 ? [2.5 , 2.23 , 0.7]: > size==5 ? [3.5 , 2.8 , 0.8]: > size==6 ? [4 , 3.36 , 1]: > size==8 ? [5.5 , 4.5 , 1.25]: > size==10 ? [7 , 5.66 , 1.5]: > size==12 ? [8.5 , 6.8 , 1.75]: > size==16 ? [12 , 9,1 , 2]: > size==20 ? [15 , 11.44 , 2.5]: > size==24 ? [18 , 13.6 , 3]: > ((this below is the line with the error. It puts it at the first bracket > before "size")) > function pointdiameter(size) = socketsetscrewsizes(size)[ pointdiameter]; > function socket(size) = socketsetscrewsizes(size)[ socket]; > function pitch(size) = socketsetscrewsizes(size)[ pitch]; > > > pd = pointdiameter(size); > s = socket(size); > pitch = pitch(size); > l = length; > offset = (size-pd)/2; > module iso_4026(size , length) { > difference() { > hull() { > cylinder(h=l,d=pd); > translate([0,0,pitch])cylinder(h=l-pitch-offset,d=size) > } > cylinder(h=size*s, d=s, $fn=6,center=true); > } > > } > > Sent with ProtonMail <https://protonmail.com/> secure email. > > > > ---------- Forwarded message ---------- > From: 3dcase via Discuss <discuss@lists.openscad.org> > To: "discuss@lists.openscad.org" <discuss@lists.openscad.org> > Cc: 3dcase <3dcase@protonmail.com> > Bcc: > Date: Tue, 05 Apr 2022 08:26:26 +0000 > Subject: [OpenSCAD] parser error: syntax error....but cannot find it! > _______________________________________________ > OpenSCAD mailing list > To unsubscribe send an email to discuss-leave@lists.openscad.org >
3
3dcase
Tue, Apr 5, 2022 8:51 AM

Ok, now I am not sure how to proceed, here as emails or where?
Till now the 2 answers already helped.I had left out a line with default parameters ending in a semi colon. this caused the first error in the line just below it.
I also had a comma where there should have been a point, easy fix but thanks to Will for spotting that one.
Now it proceeds further but I now come indeed at the size as parameter and as function issue.
Back to the drawing board and find a work around. Just wish it would point better at what IS wrong rather than at what is the RESULT of what is wrong.

Sent with ProtonMail secure email.
------- Original Message -------
On Tuesday, April 5th, 2022 at 11:39 AM, Will Hardiman bill.hardiman1995@gmail.com wrote:

This may not fix the problem, but some things I have noticed that I am uncertain of:
Your function socketsetscrewsizes doesn't appear to be terminated with a semicolon.
You seem to use size as a variable in the second half of the code (e.g. pd = pointdiameter(size);) but I can't see where it is assigned.

You have a variable called pointdiameter, and a function called pointdiameter. Does openscad allow this?
The vector for size==16 has 4 elements ( probably a comma in place of a decimal point).
In my experience, openscad is not very good at telling you where the error actually comes from, so perhaps any one of these could be causing it. Or not.
Cheers,Will

On Tue, 5 Apr 2022, 09:27 3dcase via Discuss, discuss@lists.openscad.org wrote:

---------- Forwarded message ----------
From: 3dcase 3dcase@protonmail.com
To: "discuss@lists.openscad.org" discuss@lists.openscad.org
Cc:
Bcc:
Date: Tue, 05 Apr 2022 08:26:26 +0000
Subject: [OpenSCAD] parser error: syntax error....but cannot find it!
Hello at the Openscad forum,
trying my first code with a lookup function from a list, and I get a parser error: syntax error. The problem is that I cannot find what it wants from me. I copied an existing syntax, but I must be missing something because that works and mine does not.
A hint with a little explanation would be really appreciated.

$fn=60;//flat point set screw is according ISO 4026//cone point set screw is according ISO 4027//cup point set screw is according ISO 4029//example//iso_4026(size=1.6, length=3);pointdiameter=0;socket=1;pitch=2;//size==X ? [pointdiameter, socket, pitch]:function socketsetscrewsizes(size)=size==1.6 ? [0.8 , 0.78 , 0.35]:size==2 ? [1 , 0.98 , 0.4]:size==2.5 ? [1.5 , 1.4 , 0.45]:size==3 ? [2 , 1.66 , 0.5]:size==4 ? [2.5 , 2.23 , 0.7]:size==5 ? [3.5 , 2.8 , 0.8]:size==6 ? [4 , 3.36 , 1]:size==8 ? [5.5 , 4.5 , 1.25]:size==10 ? [7 , 5.66 , 1.5]:size==12 ? [8.5 , 6.8 , 1.75]:size==16 ? [12 , 9,1 , 2]:size==20 ? [15 , 11.44 , 2.5]:size==24 ? [18 , 13.6 , 3]:((this below is the line with the error. It puts it at the first bracket before "size"))function pointdiameter(size) = socketsetscrewsizes(size)[ pointdiameter];function socket(size) = socketsetscrewsizes(size)[ socket];function pitch(size) = socketsetscrewsizes(size)[ pitch];

pd = pointdiameter(size);s = socket(size);pitch = pitch(size);l = length;offset = (size-pd)/2;module iso_4026(size , length) {difference() {hull() {cylinder(h=l,d=pd);translate([0,0,pitch])cylinder(h=l-pitch-offset,d=size)}cylinder(h=size*s, d=s, $fn=6,center=true);}
}

Sent with ProtonMail secure email.

---------- Forwarded message ----------
From: 3dcase via Discuss discuss@lists.openscad.org
To: "discuss@lists.openscad.org" discuss@lists.openscad.org
Cc: 3dcase 3dcase@protonmail.com
Bcc:
Date: Tue, 05 Apr 2022 08:26:26 +0000
Subject: [OpenSCAD] parser error: syntax error....but cannot find it!


OpenSCAD mailing list
To unsubscribe send an email to discuss-leave@lists.openscad.org

Ok, now I am not sure how to proceed, here as emails or where? Till now the 2 answers already helped.I had left out a line with default parameters ending in a semi colon. this caused the first error in the line just below it. I also had a comma where there should have been a point, easy fix but thanks to Will for spotting that one. Now it proceeds further but I now come indeed at the size as parameter and as function issue. Back to the drawing board and find a work around. Just wish it would point better at what IS wrong rather than at what is the RESULT of what is wrong. Sent with ProtonMail secure email. ------- Original Message ------- On Tuesday, April 5th, 2022 at 11:39 AM, Will Hardiman <bill.hardiman1995@gmail.com> wrote: > This may not fix the problem, but some things I have noticed that I am uncertain of: > Your function socketsetscrewsizes doesn't appear to be terminated with a semicolon. > You seem to use size as a variable in the second half of the code (e.g. pd = pointdiameter(size);) but I can't see where it is assigned. > > You have a variable called pointdiameter, and a function called pointdiameter. Does openscad allow this? > The vector for size==16 has 4 elements ( probably a comma in place of a decimal point). > In my experience, openscad is not very good at telling you where the error actually comes from, so perhaps any one of these could be causing it. Or not. > Cheers,Will > > On Tue, 5 Apr 2022, 09:27 3dcase via Discuss, <discuss@lists.openscad.org> wrote: > > > > > > > > > ---------- Forwarded message ---------- > > From: 3dcase <3dcase@protonmail.com> > > To: "discuss@lists.openscad.org" <discuss@lists.openscad.org> > > Cc: > > Bcc: > > Date: Tue, 05 Apr 2022 08:26:26 +0000 > > Subject: [OpenSCAD] parser error: syntax error....but cannot find it! > > Hello at the Openscad forum, > > trying my first code with a lookup function from a list, and I get a parser error: syntax error. The problem is that I cannot find what it wants from me. I copied an existing syntax, but I must be missing something because that works and mine does not. > > A hint with a little explanation would be really appreciated. > > > > $fn=60;//flat point set screw is according ISO 4026//cone point set screw is according ISO 4027//cup point set screw is according ISO 4029//example//iso_4026(size=1.6, length=3);pointdiameter=0;socket=1;pitch=2;//size==X ? [pointdiameter, socket, pitch]:function socketsetscrewsizes(size)=size==1.6 ? [0.8 , 0.78 , 0.35]:size==2 ? [1 , 0.98 , 0.4]:size==2.5 ? [1.5 , 1.4 , 0.45]:size==3 ? [2 , 1.66 , 0.5]:size==4 ? [2.5 , 2.23 , 0.7]:size==5 ? [3.5 , 2.8 , 0.8]:size==6 ? [4 , 3.36 , 1]:size==8 ? [5.5 , 4.5 , 1.25]:size==10 ? [7 , 5.66 , 1.5]:size==12 ? [8.5 , 6.8 , 1.75]:size==16 ? [12 , 9,1 , 2]:size==20 ? [15 , 11.44 , 2.5]:size==24 ? [18 , 13.6 , 3]:((this below is the line with the error. It puts it at the first bracket before "size"))function pointdiameter(size) = socketsetscrewsizes(size)[ pointdiameter];function socket(size) = socketsetscrewsizes(size)[ socket];function pitch(size) = socketsetscrewsizes(size)[ pitch]; > > > > pd = pointdiameter(size);s = socket(size);pitch = pitch(size);l = length;offset = (size-pd)/2;module iso_4026(size , length) {difference() {hull() {cylinder(h=l,d=pd);translate([0,0,pitch])cylinder(h=l-pitch-offset,d=size)}cylinder(h=size*s, d=s, $fn=6,center=true);} > > } > > > > > > Sent with ProtonMail secure email. > > > > > > ---------- Forwarded message ---------- > > From: 3dcase via Discuss <discuss@lists.openscad.org> > > To: "discuss@lists.openscad.org" <discuss@lists.openscad.org> > > Cc: 3dcase <3dcase@protonmail.com> > > Bcc: > > Date: Tue, 05 Apr 2022 08:26:26 +0000 > > Subject: [OpenSCAD] parser error: syntax error....but cannot find it! > > _______________________________________________ > > OpenSCAD mailing list > > To unsubscribe send an email to discuss-leave@lists.openscad.org