Hi All,
I tried this and initially had the same problems but have now solved it.?!
Put your subroutines in a numbered file, not a named one.
This is the norm for industrial controllers anyway.
Make sure the number is above the 1 to 54 -56 ( can't remember which) numbers used in parameter passing to subs.
As I use 1xx numbers for subs normally, I went to 2xx for external files
Make sure your file path is set in the .ini file as previously mentioned.
File 1 - test.ngc
(MSG,1)
O200 CALL
(MSG, 3)
M2
File2 - 200.ngc
O200 Sub
(MSG,2)
O200 Endsub
M2
This will result in the correct output of 1, 2, 3 on the message line
Note the calling syntax is the same as numbered subs in the same code file and no < > brackets.
No matter what I put in those, I could not get named files to work.
Someone on the emc-users lists suggested putting
[RS274NGC]
LAZY_CLOSE = 1
in the .ini file.
From research, this appears to enable O calls from the MDI line but has no effect on calling from within .ngc code
regards
ArcEye
PS
The number that I was trying to remember was 60.
1 - 30 are the possible parameters to the sub routine and 31 - 60 the possible return values.
I don't know if there is a possibility of a clash, but seems sensible to avoid anything which could confuse the controller, or oneself!