You are here: Building the Model: Advanced Elements > Subroutines

Subroutines

A subroutine is a user-defined command that can be called to perform a block of logic and optionally return a value. Subroutines may have parameters (local variables) that act as variables local to the subroutine and that take on the values of arguments (i.e., numeric expressions) passed to the subroutine. Additionally, a subroutine can return either an integer value or a real value to the logic or property field that called the subroutine.

ProModel handles subroutines in three ways. First, a subroutine may be processed by the calling logic as though the subroutine is part of the calling logic. This way is the most commonly used, and is done by simply referencing the subroutine by name in some logic or expression. Second, a subroutine may be processed independently of the calling logic so the calling logic continues without waiting for the subroutine to finish. This method requires an Activate statement followed by the name of the subroutine. See Activate for more information. Third, ProModel allows subroutines written in an external programming language to be called through the Xsub() function.

Subroutines can be constructed in the Subroutines editor which is accessed from the Home ribbon tab.

How to create and edit subroutines:

  1. Select Subroutines from the Home ribbon.
  2. In the Subroutines editor, provide the name, type of return value (if any), parameters, and logic for the subroutine.
  3. Refer to the following subsections for the procedures by which you can construct a subroutine.

 

© 2019 ProModel Corporation • 705 E Timpanogos Parkway • Orem, UT 84097 • Support: 888-776-6633 • www.promodel.com