RedCrab Calculator
 

Hotels Combined INT


 
Shawacademy.com

Homesquare.com
Available in RedCrab PLUS  
Programming of external functions
  • RedCrab includes an integrated application interface (API). The API can send data to external programs for calculation

  • The RedCrabAPI.dll file must be included in the external programs to communicate with RedCrab. Find the file in RedCrabs subdirectory tools/bin

  • The external programs can be written in any programming language. Important is that a development system is used which allows the API file to mount

  • This page describes the programming in the programming language Basic. As a development tool, the Microsoft Visual Studio Express is used. The Visual Studio Express can be downloaded for free from the Microsoft server. It supports C++, c#, Visual Basic and other programming languages


Program example in Visual Basic
  • For the following example, a new Windows Forms project is opened in Visual Studio
  • In Solution Explorer, add references to RedCrapApi.dll and System.Numerics. The description of this here
  • The following example shows the minimal source code of an external program. It calculates the square root of the argument. The function Transfer is the handler which is called directly from the RedCrab worksheet via the pipe
 
Line 2: Import of the RedCrabApi.

Line 6: Form1_Load event handler is executed at start of the program.

Line 7: Initialization of the RedCrab Transfer event handler. The handler is called if RedCrab sends data.

Line 10: Initialization of the pipe client. The argument of 0 specifies that the communication should be handled via the pipe number "0".

Line 12: Implementation of the RedCrab Transfer event handler.

Line 14: The send data is assigned to the Vaiable d.

Line 15: Calculate result and send to RedCrab.
   
In the following example the program above is expanded to additional lines.
 
 
Line 10 In this line, the sub-routine Info (implementation in line 32) is initialized as Info event handler.

To this handler, the API sends status messages, e.g. when data is sent or will receive. The messages are sent as a text string in the argument e.Message. They are for information only and do not affect the function. In the example above, the text will be displayed in the windows TextBox.
   
Line 18 In this line, the sent data type is checked. This test should always be done. Through the assignment of an incorrect data type, such as decimal rather than double, or is a list or table, the program will crashes.

If different data types are expected, appropriate routines can be installed for various types. Find a list of possible types below.
   
Line 21 Checks the optional command strings. Send the optionally command string to run various functions for the same data type. In the example above the result is the square of the argument, if e.Command is "square". Otherwise, the argument is multiplied by 2.
   
Line 27
Sends an error message as text to RedCrab if an invalid data type was sent.
   
   
List of allowed data types
 
  • Data type can be double, decimal, complexor string.

  • The supported formats are simple values, single-column lists and two-dimensional tables

  • The sent format element is indicated by the corresponding RedCrabDataType


List of items defined in RedCrabDataType:
  Complex      
  ComplexList      
  ComplexTable      
  Decimal      
  DecimalList      
  DecimalTable      
  Double      
  DoubleList      
  DoubleTable      
  String      
  StringList      
  StringTable      
         

Elements of RedCrabEventArg

  Command String Optional command string
  Data Object The data to be calculated
  DataType RedCrabDataType The type of data to be calculated
  Length Integer Number of rows in a list or table
  Message String Message text for info handler
  Width Integer Number of columns in a table
         
 
Server Name

  • In the examples here, it is assumed that RedCrab and the external program are located on the same computer
  • If RedCrab running on another computer, you must specify the name of the host in the NamedPipeClient ServerName
 
The following image shows an example in C#.
 
 
-
           
  Products RedCrab Calculator RedCRab Manual  
      RedCrab Software - Singapore - Sengkang West Way