soubroutine overloading ( calling it with different types, or number, of variables )
hello everybody overloading involves sending, to a same named soubroutine, different types ( or number ) of arguments ( osp variables )
in other words, the CALL statement is variable, but not like a parametric soubroutine, which always deals with a fix number of variables, but with different values
a parametric soubroutine delivers kind-of similar behaviours, while an overloaded soubroutine delivers a wider-range behaviours
example of different CALL statements, for an overloaded soubroutine :
1) using at least one variable
- for example, using CALL OSUB V1=1 V2 V3 or CALL OSUB V1=2 V2 V3
- inside OSUB should be a conditional function, that will behave differently, depending on V1 value
- V1 is a "critical argument", since it's value tells the soubroutine how it must behave
- for complex codes, overloading may require at least 2 "critical arguments"
2) using combinations of local variables : one, many, or none
- for example, using CALL OSUB or CALL OSUB ILK = 0
- this approach does not always require the presence of a "critical argument"
- in other words, the overload behaviour is not mainly triggered by the value of a "critical argument", but by it's presence
- the soubroutine will check if the "critical argument" exists, and behave accordingly
- it works only with local variables, since they can be created on demand
- this method is recommended when boolean / on-off / dual state behaviours are desired
- also local variables names are more suggestive then common variable, making the code easier to read
overloading does not deliver quicker execution times, thus it is not there to shave seconds, but only for code grammar
pls check next examples :
Code:
dehoting a classic iso-code; this :
G00 X Y Z
G01 X Y feed
G02 X Y R
G03 X Y R
may be replaced with this :
X Y Z RR
X Y feed
X Y RC
X Y RT
call o**** ILK = whatever
i like to use ILK like a programmable interlock inside a soubroutine, so to skip some safety checks, and output a particular motion
other examples when i use overload :
... when computing shortest path for C axis, so to handle C_actual_position for codes with or without compensation
... for CZ milling, so to toogle between linear & arch interpolation
... for turret indexing with low clearance, under certain conditions
... for recording absolute or relative time, in time-log soubroutines
kindly
Ladyhawke - My Delirium, https://www.youtube.com/watch?v=X_bFO1SNRZg