Create a new code module containing the callback
functions:
All callback functions and the parameter definition
structure should be declared static
except the InitializeProcess function.
This allows
you to use the same basic function and structure
names in different code modules and to create new
processes by copying existing code modules and
making minor changes.
Only the InitializeProcess function will be
visible from outside of the module.
The code module contains a static array of structures which
describes the
parameters of the process:
static DIALOGENTRY ParamDef[] =
{
{"Split Element (at +/-)", TYPE_INDEX, ARGUMENT(Data.SplitCurvePoint.pCurve), 0},
{"Point from Element (at +/-)", TYPE_INDEX, ARGUMENT(Data.SplitCurvePoint.pPoint), 0},
{NULL, 0, 0, 0}
};
Each array element contains a description of the parameter, including
hints for the valid range and the use of a sign. Use the following
typical hints:
(at +/-) to indicate first or last point, (a...b) to indicate a
range of valid parameter values from 'a' to 'b', (0/1/2) to indicate
a switch which can be 0,1, or 2.
The next structure element can be one of the following:
TYPE_INDEX ... an incrementable entity index,
TYPE_ARRAY ... an allocatable array of incrementable entity indices,
TYPE_VALUE ... a simple numeric value, no index, no string,
TYPE_STRING... a string.
The next argument specifies the offset of the structure member which holds
the actual parameter.
Use the ARGUMENT() macro to let the compiler calculate this
offset for you.
The last field of the structure is used for TYPE_ARRAY
parameters only. Allocatable arrays are represented in the process
data structure by two variables: an element count and a pointer
to 'element count' PSTR pointers, pointing to the individual elements.
The last field in a DIALOGENTRY entry specifies the offset of the structure
member which holds the element count (the number
of array elements) for the allocated array. You should set this parameter
to zero if you did not specify a TYPE_ARRAY parameter.
All entries in the last element of the DIALOGENTRY array must be set to ZERO
to indicate the end of the array!
InitializeProcess()
The InitializeProcess function will be called under
two contexts:
- when a new script line is interpreted, the parameter
szLine is pointing to the script line, and
- when a new process is inserted; in this case szLine is NULL.
First, the function should set the structure member pInfoText
before forking into two branches.
The branch for the first call context will collect the parameters from
the script line.
This is typically done using the functions
GetNextParameter()
and GetAllParameters() which scan the input line, allocate
a buffer and return a pointer to the buffer.
If you want to do your own parsing, beware of the fact, that the
Get...Parameter...() functions use the strtok()
library routine to parse the input line.
See the Concat1stLayers
module for an example how to parse the input line using strtok().
The second branch usually just calls ParameterDialog()
function, supplying a pointer to the DIALOGENTRY structure.
After one of the branches has been executed, the remaining
members of the process structure can be set.
It is important to call ParameterDialog()
before setting the process structure members !
FreeProcess()
The FreeProcess function has to free all the memory blocks
that have been allocated for the parameters of the process.
WriteSaveProcFile()
The WriteSaveProcFile function writes the process parameters
to the script file. The calling routine has already written the
header of the script line and will add the trailer of the line.
CreateListEntry()
The CreateListEntry function fills a buffer with a short
representation of the script line, that will be displayed in the
process script list window.
ShowParents()
The ShowParents function is responsible for the display
of all process parents of the supplied process.
It returns the new y-coordinate of the process tree, that
has been returned from calls to ShowProcessParents()
or to supplied y-coordinate (nY) if no call to
ShowProcessParents() has been made.
IncrementProcess()
The IncrementProcess function typically calls the
Increment() function to increment or decrement
the arguments of the supplied process. It is called when
processes are inserted or deleted in front of the process.