How can I use subscripts in ComPython object?
ComPython has a different approach to subscripting as compared to ComDPL. Two methods are shown below:
- Define a subfunction inside your *.py file. This subfunction can later on be used at any place of your *.py file. It is only important that the subfunction is properly defined and properly called. To do this refer to the Python literature. Below, a small example is provided:
def subfunction(): # definition of subfunction with def nameOfTheSubfunction
app.PrintPlain('This text comes from a subfunction') #what the subfunction does
subfunction() # calling later the subfunction
2. Define a module that contains code of your subscript and import it in the corresponding *.py file.
- *.py file
import sys #importing sys module
sys.path.append(r'C:\Users\....\Desktop') #appending path where module is saved
import moduleSubRoutine #importing module
moduleSubRoutine.Function1(app) #calling functions defined in module
app.PrintPlain('Contents of the subscript code')