Does any one have any examples of how to do a program call from within another program? KR6-1, KRC-1 controller, Software Version 2.3
Program Calls
-
drummerboyyy -
October 25, 2012 at 2:58 PM -
Thread is marked as Resolved.
-
-
You have several different ways of doing it.
One way is to put in your dat file of the routine an external call
EXT Program(Int :IN,REAL :IN )
Then you can call it from your .Src File
its been a while since ive played with a KRC1, but On a KRC2 you can just define the program as global
GLOBAL DEF FOO()
ENDThen you can just call it from anywhere you want.
-
Here is what I am trying to do. Where would I put GLOBAL DEF FOO() ? I am trying to Call a program called A91118.SRC that has all my weld positions.
END1. INI
2. LOOP
3. –
4. ;Push Station Ready Button
5. WAIT FOR IN 53 ‘STATION READY’ State=TRUE
6. –
7. PTP HOME Vel= 100 % Defualt
8. -
9. ;Index Table
10. INDX_TBL ( )
11. ;Index Complete
12. –
13. ;Weld Side A
14. ;insert program call here
15. –
16. –
17. ;Index Table
18. INDX_TBL ( )
19. ;Index Complete
20. –
21. ;Weld Side B
22. ;insert program call here
23. –
24. –
25. PTP HOME Vel= 100 % Defualt
26. –
27. ENDLOOP -
A91118() should get you what your looking for, especially if it is a standalone .src
if that gives you problems, in your .dat file for this program put
EXT A91118()
-
Thanks for your help! Your examples helped solve the problem!!
-
Greetings.
I am relatively new to KRC programming, but not new to programming itself.
I have a program in which there are many calls to the same sub-routine, like below (global sub-routine, src/dat):
04 PTP …
05 Routine (1)
06 LIN …
07 Routine (2)
08 PTP …
09 Routine (3)
10 LIN …
11 Routine (4)
12 PTP HOME
In all the examples I have, the call for a routine is done with the following syntax “Routine ()”, so my question is, what are the incremental for?I appreciate your time and effort in answering my question.
Kai -
They are the values which are passed to the sub-routine, if these values are not required then you can just use Routine ().
Sent using Tapatalk 2.
-
When you call a routine or function in KRL, any value(s) or variable(s) inside the parentheses are values or variables that are being sent to the called routine. So in your example, ROUTINE() might look something like this:
-
Thank you both, really appreciated...
-
Just one more thing: can I use an integer variable as pointer for the call of the routine, or must it be a constant?
Example:
Straight call: Routine()
Constant pointer call: Routine (3)
Variable pointer call: Routine(var)Thanks again
-
Passing arguments to a routine or function in KRL can be done two ways: by value, and by reference. This is controlled by the DEF line for the routine:
CodeDEF Routine (IntVariable :IN, RealVariable :OUT) DECL INT IntVariable DECL REAL RealVariable END
Then you call Routine like so:
Var1 will be unaffected, regardless of what Routine() does to IntVariable. This is because the DEF line sets up IntVariable to only receive the value of Var1 -- hence the :IN. Var2, however, will be affected by whatever Routine() does to RealVariable, due to the :OUT -- this causes the memory location of Var2 to be "shared" to Routine(), rather like sending pointers in C.