< previous page page_531 next page >

Page 531
G.6
Function Names for Visual Basic and Delphi
The names of the functions have been changed in the BASIC module to be more like Visual Basic names. For example:
Declare Function ArabicToRoman Lib "SCDTL" & _Alias "arabic_to_roman_2"
    (ByVal n As Long, ByVal s As String) As Long
The C function arabic_to_roman is referenced as "ArabicToRoman" in Visual Basic.
See SCDTL.BAS for the Visual Basic function declarations. The function calls were tested with Visual Basic 5.
The same naming convention was used for Delphi. See SCDTL.PAS for the Delphi function declarations. The function calls were tested with Delphi Version 2.0.
G.7
Wrapper Functions for Visual Basic and Delphi
Certain functions did not make themselves easily callable from Visual Basic and Delphi. Rather than change the original function, a wrapper function was created. An example is month_name (referenced as MonthName from VB and Delphi). The C prototype for month_name is:
char *month_name (int month_index);
A wrapper was created so that a string was a parameter instead of a return value:
int month_name_2 (int month_index, char *name);
The return value is the length of the returned string. The Visual Basic and Delphi declarations reference the month_name_2 function:
Declare Function MonthName_2 Lib "SCDTL" & _ Alias "month_name_2" & _
    (ByVal month_index As Long, ByVal month_name As String) As Long
and have the following wrapper function return the month name string:
Public Function MonthName(month_index As Long) As String
    Dim s As String
    s = String(10, vbNullChar) ' max of 10 chars including null terminator
    l = MonthName_2(month_index, s)
    s = Left(s, l)
    MonthName = s
End Function

 
< previous page page_531 next page >