sub_program_run(name)
Features
It executes a subprogram saved as a separate file.
Parameter
Parameter Name | Data Type | Default Value | Description |
---|---|---|---|
name | string | - | Name of subprogram |
Return
Value | Description |
---|---|
module | Module object of executed subprogram |
Exception
Exception | Description |
---|---|
DR_Error (DR_ERROR_TYPE) | Parameter data error occurred |
DR_Error (DR_ERROR_VALUE) | Parameter value is invalid |
DR_Error (DR_ERROR_RUNTIME) | C Extension module error occurred |
DR_Error (DR_ERROR_STOP) | Program terminated forcefully |
Note
- The first line of the subprogram must have the phrase "from DRCF import *".
- When programming with a teaching pendant, this phrase is automatically inserted.
- If the global variable names of the main program and subprograms are the same, they operate as different variables. Variables cannot be referenced by each other.
- If you need to share variables between the main program and subprograms, use system variables.
- System variables are set through the teaching pendant. Please refer to the user manual for detailed usage.
Example
# subprogramA and subprogramB must be created and saved in advance.
<subProgramA.drl>
from DRCF import *
movej([0,0,90,0,90,0], vel=30, acc=30)
<subProgramB.drl>
from DRCF import *
movej[(10,0,90,0,90,0), vel=30, acc=30)
<main program>
while True:
var_select = tp_get_user_input("Select File", DR_VAR_INT)
if var_select == 0:
sub_program_run("subProgramA") # execute subProgramA
elif var_select == 1:
sub_program_run("subProgramB") # execute subProgramB