Calling Subcharts

To call a subchart defined in a Raptor program, simply insert a Call symbol at the desired spot in your program, double-click on the Call symbol to edit it, and enter the name of the subchart to be called there.  A subchart may be called from the Main flowchart or from other subcharts (even from within itself, but this is usually not a good thing to do!).

 

Passing Data to and from Subcharts (Advanced Topic)

 

You may have noticed that one nice thing about many built-in Raptor procedures is that the programmer can change their behavior by passing different arguments, or parameters, to the procedures.  For example, I can use the same Draw_Circle routine to draw a red circle at coordinate (100,100) and to draw a black circle at coordinate (250,250).  It would be nice to have this capability with Raptor's subcharts.

 

Raptor subcharts do not support passing of arguments or parameters in the style of the built-in routines.  However, this limitation can be overcome with careful use of variables.

 

The general idea is that a subchart will have special variables used to communicate information with the rest of the program.  To ensure these variables aren't used elsewhere in the program, it would be wise to name them in a unique way.  A good naming convention might be to start the variable names with the subchart name and an underscore (e.g., draw_triangle_x might be an argument variable for a subchart called draw_triangle).  

 

To simulate the use of arguments that provide a value to the subchart, the program must first copy (using assignment symbols) required values into the appropriate special subchart variables before the subchart is called.  After the call to the subchart, the program must copy .  (again using assignment symbols) any values that the subchart has computed for later use by our program (we might call these results of the subchart's computation).   These must be copied from the subchart-specific variables to appropriate "permanent" program variables.