Subroutines

Objects can be passed as arguments to subroutines and subroutines can return objects. It is necessary to prefix the object symbol name with the keywork OBJECT in both the calling GOSUB and in the placeholder of the DEFSUB as in

OBJECT Sheet = 'CreateExcelObject()
'DoExcelStuff(OBJECT Sheet)
DEFSUB 'DoExcelStuff(OBJECT s)
DEFSUB 'CreateExcelObject()
LOCAL DIM OBJECT a
	...
RETURN OBJECT a

Objects are allowed to be passed into DEFSUBs only (not DEFFNs) and as the object will therefore be local its object reference lifetime will be only for the lifetime of the routine.