EnglishРусский  
The project is closed! You can look at a new scripting language. It is available on GitHub.
Also, try our open source cross-platform automation software.

Ads

Installer and installation software
Commercial and Freeware installers.

Subfunction declaration: subfunc

Subfunctions are defined in the body of the function with the help of the subfunc construction. A subfunction is defined in the lowest level of the embedded block of the body. You can call a subfunction only from the function body as well as from other subfunctions of the given function. It is impossible to define another subfunction and to call itself recursively, because local variables are considered to be static. A subfunction is able to redefine other functions' names. A subfunction is actually called like a function; moreover, a subfunction as well as its parameters are declared in much the same way as the function, except for the lack of attributes. You can use local variables of the function within the subfunction.

Subfunctions are very usefull when you need to execute the same code some times inside the function but you do not want to describe an independent function.

func uint myfunc( int par )
{
   int locvar
   subfunc int mysubfunc( int subpar )
   {
      return locvar + par + subpar
   }

   locvar = mysubfunc( 5 )
   par = mysubfunc( 10 ) + mysubfunc( 20 )
}

Related links