extension for Serf Software and math library.

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.

An example in Basic

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 Long
Dim x(100) As Single, y(100) As Single
ilen = 100
For i = 0 To ilen - 1
    x(i) = i
    y(i) = i * i
Next i
ret = S_XYPlot(x(0), y(0), ilen, "s", "nM")
PostError (ret)
Sub PostError(error As Long)
    If (error >= 0) Then
        Exit Sub
    ElseIf (error > -100) Then
        S_Error (error)
    Else: MsgBox "DDL error"
    End If
End Sub


The 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.

Mandel.exe, a C++ example

Mandel is a program that calculates the by now classical images of (parts of) the Mandelbrot set that can then possibly be viewed as an animation in the CellsAndMaps program. It also outputs graphs that show the trajectory of the iteration: xn+1F(xn,c). These graphs are then automatically displayed by for example XLPlot.The following fragments of C++ have been created with the free Borland C++ 5.02 compiler and linker.
First the location where your Serf Software program is located is determined:

bool TJRMDIClient::FindSerfDirectory()
{  char string[64];
   char directory[128];
   FILE* inifile;
   strcpy(directory,"C:\\Documents and Settings\\All Users\\Application Data\\Serf\\");
   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);
      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:


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:

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.