7.4

Table Of Contents
Name to use for the function, prefixed with the @ character. The name must conform to the rules for names described in
"Names" (page 221). It is good practice to be careful naming functions that you define in different documents, to ensure that if
at some point you want to copy code between documents, the names of functions do not conflict.
arglist
List of arguments the function requires, where each element in the list has the syntax varname : type. For example, &date :
string. An ampersand always precedes the first letter of varname. A comma separates each element in the list. Note that all
arguments are pass by value (as opposed to pass by reference). Pass by value means that the function you define cannot mod-
ify any of the arguments it receives. Any modifications you make to an argument within the body of the function are made to a
local copy, and do not affect the original.
type
Type of value (integer, measure, currency, string, Boolean) the function returns.
Code Sample Example
This example displays a string.
function @showtext(&mystring: string)
moveto(1,1)
show(&mystring)
endfunction()
Code Sample Example
This example illustrates a procedure that creates a 3D pie chart.
Example
function @_3DPie( &W:measure, &H:measure, &HB:measure, &S:measure, &E:measure,
&L:string, &c:color )
%====================================================
% &W is the total width of the pie chart
% &H is the total height of the pie chart
% &HB is the height of the lower band
% &S is the starting angle (0..360)
% &E is the ending angle (0..360 and bigger than &S)
% &L is the label text
%====================================================
%Local variables
%====================================================
define(&SB,measure,0)
define(&EB,measure,0)
define(&Scaling,measure,0)
define(&R,measure,&W/2)
%====================================================
&Scaling := (&H-&HB)/&W
gsave()
if(&Scaling<0.01)
&Scaling := 0.01
endif()
©2010 Objectif Lune Inc - 423 -