Procedure Calls vs. Functions

Raptor provides the programmer with many tools in addition to the basic building blocks for flowcharts.  Chief among these are the built-in procedures and functions that perform a wide variety of tasks on the programmer's behalf, saving development time and reducing the chance for errors.  

 

Both procedures and functions have names.  Both can have zero, one, two, or more arguments.  If arguments are needed, they are listed in parentheses separated by commas after the name.  For example, the Put_Pixel procedure requires three arguments to workthe x and y coordinates of the pixel to be set and the desired color to make the pixel.  It is called in a Call symbol as shown below:

 

 

Note, though, that Put_Pixel doesn't have the notion of a value.  It simply performs a task, in this case setting the color of one pixel on the RaptorGraph window, then completes and allows program control to move to the next symbol.  

 

All procedure calls behave similarly.  That is, they must appear in the Call symbol, they perform some task, and they have no notion of a value.

 

Now consider the PowerMod function.  Like Put_Pixel, PowerMod takes three arguments as shown below:

 

PowerMod(3,4,5)

 

Unlike Put_Pixel, though, PowerMod is a function that returns a numeric value, much like sqrt(x) is a function that returns a value.  Because PowerMod returns a value, it can be called anywhere a numeric value can be used.   In fact, any numeric function can be used where ever a numeric value is legal.  Of course, a function that returns a string can be called anywhere a string value can be used.  The key concept is that a function returns a value, while a procedure call doesn't.  Finally, several functions return Boolean values, and these can be used only where a Boolean value is allowedusually in the diamond of a selection or loop.

 

So functions can be used in simple or complex expressions appearing...

 

...in an Assignment symbol:  

 

 

...in a diamond:

 

 

 

 

...in an Output symbol as part of the expression to be output:

 

 

...in an array index: