The Dynamic Link Library, JRTalk.dll, regulates the communication between Serf Sofware and a program that you may have created in Visual Basic, Media Cybernetics IP+ script or in C. It also gives access to a part of the Serf/XL-Plot math library. When calling one of its functions, the dll launches a Serf Suite program or XLPlot if (and only if) this is required and then executes the function, which may be the creation of columns of data in a spreadsheet or a graph on a drawing sheet.
With the extension, the Basic or C programmer can simulate the selection of menu items in Serf Software Suite programs or XLPlot, create new spreadsheets and drawing sheets and select ranges of spreadsheet cells to manipulate their contents.
Suppose the user prepares two arrays of floating point numbers in a Visual Basic program and then calls the S_XYPlot() function to create a new plot:
Declare Function S_XYPlot Lib "JRTalk" Alias "@S_XYPlot$qqspft1spct4" (x As Single, y As Single, ByVal ilen As Integer, ByVal xs As String, ByVal ys As String) As LongThe math library contains a number of statistical tables and functions, floating point routines such as matrix inversion, LU-decomposition, QR-decomposition, Eigen-decomposition,Fourier transformation, polynomial regression and many functions to manipulate arrays of integer or floating point numbers.
bool TJRMDIClient::FindSerfDirectory()
{ char string[64];
char directory[128];
FILE* inifile;
strcpy(directory,"C:\\Documents and Settings\\All Users\\Application Data\\Serf\\");
SetCurrentDirectory(directory);
inifile=fopen("serf.ini","r");
if (!inifile)
{ inifile=fopen("cellsandmaps.ini","r");
if (!inifile)
{ inifile=fopen("xlplot.ini","r");
if (!inifile)
{ inifile=fopen("electrophy.ini","r");
if (!inifile)
{ inifile=fopen("clusters.ini","r");
if (!inifile) inifile=fopen("sound.ini","r");}
}
}
}
if (inifile)
{ fread(serfdirectory,256,1,inifile);
fclose(inifile);
return true;}
return false;}
Then the child window in Mandel.exe, which creates the two columns of data, sets the Serf Software program directory by issuing the command:
err=S_SetProgramDirectory(Mom->serfdirectory);
where Mom refers to the TJRMDIClient window above. Mandel then creates two floating point arrays, X and Y, of dimension (length) n and sends those to the Serf Software program:
err=S_XYPlot(X,Y,n,"real","imag");
if (err<0) S_Error(err);
delete[] X;
delete[] Y;
The strings "real" and "imag" are for the text along the abscissa and ordinate of the graph. When S_XYPlot() returns, the Serf Software program has already copied the data and hence the X and Y arrays may be deleted.
Three JRTalk functions have been used in this application that are declared in a header file, Mandel.h:
long _import _stdcall int S_SetProgramDirectory(char*);
long _import _stdcall int S_XYPlot(float *x,float *y,short len,char *xs,char *ys);
long _import _stdcall int S_Error(long err);
The complete source code of version 2.03 of Mandel may be downloaded. N.B. The code has been made with Borland C++ 5.02. Copyleft/Creative Commons conditions apply.