This should be simple
- clayton cramer
- Offline
- Senior Member
Less
More
- Posts: 45
- Thank you received: 0
02 Dec 2018 06:52 #121706
by clayton cramer
This should be simple was created by clayton cramer
%
G17 G20 G54
o101 sub
g01 y2.675 f10
g01 #endX
g01 y-.375 f10
g01 z#z
g01 x#startX
o101 endsub
o101.call [#startX=.5] [#z=-.2] [#endX=.675]
o101 call [#startX=.5] ]#z=--.4] [#endX=..675]
%
The error message is: "3 - Unknown word starting with s"
It seems like subroutines do not have the keyword sub after the subroutine number. Even I can't misread the subroutine examples that badly, can I?
G17 G20 G54
o101 sub
g01 y2.675 f10
g01 #endX
g01 y-.375 f10
g01 z#z
g01 x#startX
o101 endsub
o101.call [#startX=.5] [#z=-.2] [#endX=.675]
o101 call [#startX=.5] ]#z=--.4] [#endX=..675]
%
The error message is: "3 - Unknown word starting with s"
It seems like subroutines do not have the keyword sub after the subroutine number. Even I can't misread the subroutine examples that badly, can I?
Please Log in or Create an account to join the conversation.
- phillc54
- Offline
- Platinum Member
Less
More
- Posts: 5714
- Thank you received: 2090
02 Dec 2018 10:38 #121708
by phillc54
Replied by phillc54 on topic This should be simple
Named parameters have a slightly different format, #endX should be #<endX>
Named Parameters
Named Parameters
Please Log in or Create an account to join the conversation.
- clayton cramer
- Offline
- Senior Member
Less
More
- Posts: 45
- Thank you received: 0
02 Dec 2018 14:28 #121711
by clayton cramer
Replied by clayton cramer on topic This should be simple
Progress, I think.
%
G17 G20 G54
o101 sub
g01 y2.675 f10
g01 #<endX>
g01 y-.375 f10
g01 z#<z>
g01 x#<startX>
o101 endsub
o101 call [#<startX>=.5] [#<z>=-.2] [#<endX>=.675]
o101 call [#<startX>=.5] ]#<z>=--.4] [#<endX>=..675]
%
gives: "1 - Named parameter #<startx> not defined "
All my named parameters are #<name> And linuxcnc.org/docs/html/gcode/overview.html#_named_parameters says that they "spring into existence when they are assigned a value for the first time. "
%
G17 G20 G54
o101 sub
g01 y2.675 f10
g01 #<endX>
g01 y-.375 f10
g01 z#<z>
g01 x#<startX>
o101 endsub
o101 call [#<startX>=.5] [#<z>=-.2] [#<endX>=.675]
o101 call [#<startX>=.5] ]#<z>=--.4] [#<endX>=..675]
%
gives: "1 - Named parameter #<startx> not defined "
All my named parameters are #<name> And linuxcnc.org/docs/html/gcode/overview.html#_named_parameters says that they "spring into existence when they are assigned a value for the first time. "
Please Log in or Create an account to join the conversation.
- MaHa
- Offline
- Platinum Member
Less
More
- Posts: 405
- Thank you received: 163
02 Dec 2018 15:08 #121713
by MaHa
Replied by MaHa on topic This should be simple
another option 1
;************
o101 sub
g01 y2.675 f10
g01 x#3
g01 y-.375 f10
g01 z#2
g01 x#1
o101 endsub
G17 G20 G54
o101 call [.5] [-.2] [.675]
M2
;************
another option 2
;************
o101 sub
g01 y2.675 f10
g01 x#3
g01 y-.375 f10
g01 z#2
g01 x#1
o101 endsub
G17 G20 G54
#<startX>=.5
#<z_>=-.4
#<endX>=.675
o101 call [#<startX>] [#<z_>] [#<endX>]
M2
;************
another option 3
;************
o101 sub
g01 y2.675 f10
g01 x#<_endX>
g01 y-.375 f10
g01 z#<_z_>
g01 x#<_startX>
o101 endsub
G17 G20 G54
#<_startX>=.5
#<_z_>=-.4
#<_endX>=.675
o101 call
M2
;************
;************
o101 sub
g01 y2.675 f10
g01 x#3
g01 y-.375 f10
g01 z#2
g01 x#1
o101 endsub
G17 G20 G54
o101 call [.5] [-.2] [.675]
M2
;************
another option 2
;************
o101 sub
g01 y2.675 f10
g01 x#3
g01 y-.375 f10
g01 z#2
g01 x#1
o101 endsub
G17 G20 G54
#<startX>=.5
#<z_>=-.4
#<endX>=.675
o101 call [#<startX>] [#<z_>] [#<endX>]
M2
;************
another option 3
;************
o101 sub
g01 y2.675 f10
g01 x#<_endX>
g01 y-.375 f10
g01 z#<_z_>
g01 x#<_startX>
o101 endsub
G17 G20 G54
#<_startX>=.5
#<_z_>=-.4
#<_endX>=.675
o101 call
M2
;************
Please Log in or Create an account to join the conversation.
- Todd Zuercher
- Away
- Platinum Member
Less
More
- Posts: 4957
- Thank you received: 1441
02 Dec 2018 15:52 #121717
by Todd Zuercher
Replied by Todd Zuercher on topic This should be simple
I think your problem is also the fact that you are defining your named parameters in a subprogram. For that to work I believe your parameters need to be "global named parameters". To make them global simply add an underscore to the start of the parameter name #<_name>.
Please Log in or Create an account to join the conversation.
- andypugh
- Offline
- Moderator
Less
More
- Posts: 23178
- Thank you received: 4865
03 Dec 2018 13:59 #121748
by andypugh
You seem to be mistaking G-code for a programming language
I don't know how the interpreter parsesbut I suspect it isn't the way you would like. G-code doesn't support named arguments to subs, only positional arguments
You can either set global named parameter and then use that in the sub (MaHa option 3) , or refer to the parameters by position in the sub (maHa option 1). MaHa option 2 might be preferred in a situation where the positions to be passed are calculated rather than fixed.
Replied by andypugh on topic This should be simple
Progress, I think.
%
G17 G20 G54
o101 sub
g01 y2.675 f10
g01 #<endX>
g01 y-.375 f10
g01 z#<z>
g01 x#<startX>
o101 endsub
o101 call [#<startX>=.5] [#<z>=-.2] [#<endX>=.675]
o101 call [#<startX>=.5] ]#<z>=--.4] [#<endX>=..675]
%
You seem to be mistaking G-code for a programming language
I don't know how the interpreter parses
o101 call [#<startX>=.5] [#<z>=-.2] [#<endX>=.675]
You can either set global named parameter and then use that in the sub (MaHa option 3) , or refer to the parameters by position in the sub (maHa option 1). MaHa option 2 might be preferred in a situation where the positions to be passed are calculated rather than fixed.
Please Log in or Create an account to join the conversation.
Time to create page: 0.062 seconds