How-To: Pass a class as a procedure parameter

##Question:

Is it possible to pass a StringTheory object to a procedure as a parameter? So that I can set the value of the StringTheory object in one procedure … and read it in another procedure?
Something like

MyStringTheoryObject.SetValue('ABCDE')
MyProcessingProcedure(MyStringTheoryObject)


MyProcessingProcedure PROCEDURE (StringTheory  pMyStringTheoryObject)
  Code
   SomeString = pMyStringTheoryObject.GetValue()

##Answer:

Procname PROCEDURE(*StringTheory pSTObject)

MyLocalSTObj  &StringTheory
 CODE

 MyLocalSTObj &= pSTObject
 SomeString = MyLocalSTObj.GetValue()

####Alternate:

Procname PROCEDURE(*StringTheory pSTObject)
StringOfUnknownLength ANY
 CODE
 StringOfUnknownLength = pSTObject.GetValue()

Further discussion. Bruce Johnson noted the * is redundant and not needed as objects are always passed as reference pointers.

Copied from Skype converation. Hattip to Mark Riffey for answer 1, Mark Goldberg for answer 2

1 Like

Thanks Lucas for the nice example.

Best regards
Jeffrey