Returning TEXT/BYTE values from functions

When returning a TEXT or BYTE value from a function, the locator is pushed in on the stack.

Storage information of the TEXT/BYTE is defined in the locator structure and controlled with the LOCATE instruction. The storage of the large object variable can be defined in a function, initialize the object with a value, and return it:

MAIN
  DEFINE t TEXT
  LET t = init_text(t)
  DISPLAY "t size = ", LENGTH(t)
END MAIN

FUNCTION init_text(t)
  DEFINE t TEXT
  LOCATE t IN MEMORY
  LET t = "abc"
  RETURN t
END FUNCTION
The above sample will produce following ouput:
t size =         3