Using return values from oWord subroutines
- scsmith1451
-
Topic Author
- Offline
- Senior Member
-
Less
More
- Posts: 61
- Thank you received: 2
30 Oct 2025 18:07 #337500
by scsmith1451
Using return values from oWord subroutines was created by scsmith1451
I've been trying to develop a routine to repeatedly measure the four corners of my X/Y table and its center for leveling purposes. The attached file is currently working great though it only does one set of measurements each run. The M100 code at the end of the routine is a small python routine to read the proberesults.txt file, converting the values to floats and storing them into an excel spreadsheet.
Having had success with the routine I modified it to wrap the 5 measurement calls and the M100 call in a WHILE LOOP. However, only the last set of measurements was posted to the spreadsheet. To get around this issue I would like to do the following:
1. Instead of writing each measurement to proberesults.txt, I would like the o200 subroutine to return the value of #<_z> for each measurement such that I can capture them and write a single line with all 5 measurements; i.e. (LOG,#<LF>,#<RF>,#<LR>,#<RR>,#<C>)
I capture #<_z> in a local variable, #<result> = #<_z>, then return it with:
o200 endsub [#<result>].
I've tried to assign the return value with:
#<LF> = o200 call p1,p2,p3,p4
and
o200 call p1,p2,p3,p4
#<LF> = #<_value>
and
#<LF> = [#<_value>]
All of these generate errors when I load the program file into LCNC.
What is the correct syntax for assigning return values from an oWord routine?
Kind regards,
Having had success with the routine I modified it to wrap the 5 measurement calls and the M100 call in a WHILE LOOP. However, only the last set of measurements was posted to the spreadsheet. To get around this issue I would like to do the following:
1. Instead of writing each measurement to proberesults.txt, I would like the o200 subroutine to return the value of #<_z> for each measurement such that I can capture them and write a single line with all 5 measurements; i.e. (LOG,#<LF>,#<RF>,#<LR>,#<RR>,#<C>)
I capture #<_z> in a local variable, #<result> = #<_z>, then return it with:
o200 endsub [#<result>].
I've tried to assign the return value with:
#<LF> = o200 call p1,p2,p3,p4
and
o200 call p1,p2,p3,p4
#<LF> = #<_value>
and
#<LF> = [#<_value>]
All of these generate errors when I load the program file into LCNC.
What is the correct syntax for assigning return values from an oWord routine?
Kind regards,
Please Log in or Create an account to join the conversation.
- Aciera
-
- Offline
- Administrator
-
Less
More
- Posts: 4554
- Thank you received: 2028
30 Oct 2025 18:41 #337506
by Aciera
Replied by Aciera on topic Using return values from oWord subroutines
Maybe this helps:
linuxcnc.org/docs/html/gcode/o-code.html...outine_return_values
linuxcnc.org/docs/html/gcode/o-code.html...outine_return_values
Please Log in or Create an account to join the conversation.
- scsmith1451
-
Topic Author
- Offline
- Senior Member
-
Less
More
- Posts: 61
- Thank you received: 2
30 Oct 2025 20:40 #337532
by scsmith1451
Replied by scsmith1451 on topic Using return values from oWord subroutines
Hellow Aciera,
That was the document that I was following when attempting to use the return values. I have attempted to use:
o200 call .....
#<LF> = #<_value>
but, that generates an error when the code is loaded into LCNC.
Still stuck on the assignment of the return value to a local named variable.
Kind Regards
That was the document that I was following when attempting to use the return values. I have attempted to use:
o200 call .....
#<LF> = #<_value>
but, that generates an error when the code is loaded into LCNC.
Still stuck on the assignment of the return value to a local named variable.
Kind Regards
Please Log in or Create an account to join the conversation.
- MaHa
- Offline
- Platinum Member
-
Less
More
- Posts: 464
- Thank you received: 197
30 Oct 2025 21:25 #337539
by MaHa
Replied by MaHa on topic Using return values from oWord subroutines
how to call:
o<subroutineX1> call [4.1] [3] [12]
returnvalue:
o<subroutineX1> endsub [#<FW>]
M2
returned value #<FW> as #<_value>
(debug,#<_value>)
if #<_value> is needed for further processing, its required to save to a parameter, next subroutine return will overwrite #<_value> with new returnvalue
o<subroutineX1> call [4.1] [3] [12]
returnvalue:
o<subroutineX1> endsub [#<FW>]
M2
returned value #<FW> as #<_value>
(debug,#<_value>)
if #<_value> is needed for further processing, its required to save to a parameter, next subroutine return will overwrite #<_value> with new returnvalue
The following user(s) said Thank You: Unlogic
Please Log in or Create an account to join the conversation.
- scsmith1451
-
Topic Author
- Offline
- Senior Member
-
Less
More
- Posts: 61
- Thank you received: 2
31 Oct 2025 20:01 #337598
by scsmith1451
Replied by scsmith1451 on topic Using return values from oWord subroutines
MaHa;
I tried that syntax several times and every time I would load the code a validation error would be raised.
Out of frustration, I deleted all of the code and re-typed it. This time the code loaded without error and ran perfectly.
Thanks for the encouragement.
Regards,
I tried that syntax several times and every time I would load the code a validation error would be raised.
Out of frustration, I deleted all of the code and re-typed it. This time the code loaded without error and ran perfectly.
Thanks for the encouragement.
Regards,
Please Log in or Create an account to join the conversation.
Time to create page: 0.072 seconds