Adding code for the AddInts() function to the code generated by BladeSmith

About this task

BladeSmith generates two source code files for the AddInts DataBlade® module, which you can see in Visual C++ under the Source Files node in the File view:
  • udr.c. For user-defined routines. You must add code to implement the functions in this file.
  • support.c. For tracing and BladeSmith utility functions. Do not edit this file.
BladeSmith generates the following functions for the AddInts DataBlade module, which you can see under the Globals node in the Class view:
  • AddInts(). This is the only function that you modify. It is in the udr.c file.
  • Gen_nstrwords(). A BladeSmith utility function not used in the generated code for the AddInts() function. It is in the support.c file.
  • Gen_Trace(). A BladeSmith utility function to process trace messages and errors. It is in the support.c file.

To implement the AddInts() function:

Procedure

  1. In Visual C++, double-click the AddInts() function under the Globals node in the Class view and find the following code:
    /*  
    ** TO DO: Remove this comment and call to  
    **        mi_db_error_raise after implementing  
    **        this function.  
    */  
    mi_db_error_raise( Gen_Con, MI_EXCEPTION,   
         "Function AddIntegers has not been implemented." );
  2. Remove the comment and replace the mi_db_error_raise() statement with the following code to add the two integers:
    Gen_RetVal = Int1 + Int2;
  3. Remove the following comment, the call to the mi_fp_setreturnisnull() function, and the statement that sets Gen_RetVal to 0:
    /*  
    ** TO DO: Compute and store your value into Gen_RetVal.  
    ** The call to mi_fp_setreturnisnull informs the  
    ** server that the return value is NULL.  
    */  
    mi_fp_setreturnisnull( Gen_fparam, 0, MI_TRUE );  
    Gen_RetVal = 0;
     
  4. Check your source code against the final version of udr.c.
  5. Save your changes to udr.c.