EnglishРусский  

Ads

Installer and installation software
Commercial and Freeware installers.

Returning variables

Gentee prevents returning local variables from functions and methods if the variables are not of the numeric data type. All structural local variables are deleted as soon as the function has finished executing. For example, if the next function is called, the error occurs.

func str func1
{
   return "Result string"
}

In such cases, the result attribute can be used. The attribute enables you to return a result value from functions or methods. Furthermore, using the attribute avoids defining and sending unnecessary local variables. Take advantage of this attribute in order to use the result variable, that will be returned as soon as the function has finished executing. If a function has the result attribute, the return instruction is not required or it must contain no expression.

func str myfunc<result>
{
   result = "Result string"
}

func main<main>
{
   print( myfunc())
}

Note that a function or a method of this type is called after a temprorary variable has been actually created in the calling block. The variable is sent to the function where it is used as the result variable.

Related links