The basic components of a new server procedure are explained in this annotated source for wavebar3d.pro:
The server procedure must have two arguments, an associative array containing all of the tag names and data, and the path/filename of the resulting image to be produced.
PRO WAVEBAR3D, kw, file ON_ERROR, 2Extract the tag names from the associative array
tags = ASKEYS(kw)Initialize strings to hold the positional parameter names (key) and a string to hold the name of the Z positional parameter (which will be kw("Z") in this case.)
key = '' posz = ''Loop through each tag and either add the keyword to the "key" string or to the "posz" string if it is the Z data array
FOR i=0,N_ELEMENTS(tags)-1 DO BEGIN
CASE tags(i) OF
The "WaveBar3D" tag contains the size of the plot to produce.
Here we call the convenience routine "OpenZBuff" to open and
clear the Z buffer device and set it to the desired size.
Also, particular to the Bar3D procedure, we will force the TEK_COLOR palette to be loaded.
'WaveBar3D' : BEGIN
OpenZBuff, kw(tags(i))
SET_PLOT, 'PS'
TEK_COLOR
SET_PLOT, 'Z'
END
Because the Z parameter is a positional parameter, we must store it in a separate
string so that when we assemble the call to Bar3D we can place it in the right
order. (This is a big issue if there are more than one positional parameters)
'Z' : posz = 'kw("' + tags(i) + '")'
All other keywords just get appended to the "key" string
ELSE : key = key + ', ' + tags(i) + '=kw("' + tags(i) + '")'
ENDCASE
ENDFOR
Now use EXECUTE to actually create the 3D Bar chart in the Z buffer
status = EXECUTE('BAR3D, ' + posz + key)
We use the convenience routine "CloseZBuff" to copy the contents
of the Z buffer to a variable and call the "WriteImage" procedure
to save it as a gif file.
CloseZBuff, fileThe optional "UpdateLog" procedure will update a file with a log entry for this plot.
dt_to_str, today(), d, t, date=1, time=-1 desc = 'Plot created '+d+' '+t UpdateLog, desc, file, 0 END