It's currently not possible to return more than a fixed list of variables defined by the RET keyword from WeiDU functions. This limitation makes it impossible to return dynamic data structures, such as arrays, where the final number and/or name may not be known in advance.
Would it be feasible to add a feature that allows us to return dynamically created variables, e.g. by using a new keyword that adds them to the RET list at runtime?
Example:
DEFINE_PATCH_FUNCTION array_generator
INT_VAR
array_size = 10
RET
array
BEGIN
FOR (i = 0; i < array_size; ++i) BEGIN
SET EVAL ~array_%i%~ = i
EXPORT ~array_%i%~ // mark variable "array_%i%" as a return value
END
SET array = array_size
END
Currently only "array" will be defined outside the function. Evaluating "%array_0%" will only result in the string "%array_0%".