Returning dictionaries from functions

When returned by a function, dictionaries are pushed on the stack by reference.

Therefore, you can create a dictionary in a function and return it to the caller for usage:

MAIN
  DEFINE dic DICTIONARY OF STRING
  LET dic = create_dictionary(10)
  DISPLAY dic["item3"]
  DISPLAY dic["item10"]
END MAIN

FUNCTION create_dictionary(n)
  DEFINE n, i INTEGER
  DEFINE dic DICTIONARY OF STRING
  FOR i=1 TO n
     LET dic[SFMT("item%1",i)] = SFMT("This is item %1",i)
  END FOR
  RETURN dic
END FUNCTION