Comparing C/C++, C#, VB and ATEasy Basic Data Types

Knowledge Base Article # Q200210

Read Prior Article Read Next Article
Summary This article can be used to cross-reference between C/C++, C#.NET, and VB.NET and possible equivalent ATEasy data types. It is useful when calling external DLLs from ATEasy or when calling ATEasy DLLs from other programming languages.
  
Login to rate article

Data type reference table

The following table describes ATEasy equivalent data types when calling procedures defined in other programming languages such as C/C++. The table also shows the suggested ATEasy data types used when importing C/C++ header file to ATEasy; these suggestions are offered using the ATEasy Ambiguous C Type Dialog (see ATEasy on-line help for more information):

C/C++C#.NETVB.NETATEasy Description
signed charsbyteByVal SByteVal CharSigned 8-bit integer
signed char *sbyte *ByRef SByteVal String, Var String, Val Char[ ], Var Char[ ]Pointer to a single or an array of signed 8-bit integer characters
unsigned charbyteByVal ByteVal ByteUnsigned 8-bit integer
unsigned char *byte *ByRef ByteVal Byte, Var Byte[ ], Val Byte[ ]Pointer to a single or an array of unsigned 8-bit integer
boolboolByVal BooleanVal BoolBoolean data type (True <>0/False 0), True is usually -1 but in C data type BOOL is 1
bool *bool *ByRef BooleanVar Bool, Var Bool[ ], Val Bool[ ]Pointer to a single or an array of boolean data type (True/False)
signed short intshortByVal ShortVal ShortSigned 16-bit integer
signed short int *short *ByRef ShortVar Short, Var Short[ ], Val Short[ ]Pointer to a single or an array of signed 16-bit integer
unsigned short intushortByVal UShortVal WordUnsigned 16-bit integer
unsigned short int *ushort *ByRef UShortVar Word, Var Word[ ], Val Word[ ]Pointer to single or an array of unsigned 16-bit integer
wchar_tcharByVal CharVal WCharUnicode 16-bit integer
wchar_t *char *ByRef CharVar WChar, Val BString, Var BString, Val WChar[ ], Var WChar[ ]Pointer to single or an array of Unicode 16-bit integer
signed intintByVal IntegerVal LongSigned 32-bit integer
signed int *int *ByRef IntegerVar Long, Var Long[ ], Val Long[ ]Pointer to single or an array of signed 32-bit integer
unsigned intuintByVal UIntegerVal DWordUnsigned 32-bit integer
Var DWord, Var DWord[ ], Val DWord[ ]unsigned int *uint *ByRef UIntegerPointer to a single or an array unsigned 32-bit integer
floatfloatByVal SingleVal Float32-bit floating-point (single precision)
float *float *ByRef SingleVar Float, Var Float[ ], Val Float[ ]Pointer to a single or an array of 32-bit floating-point
doubledoubleByVal DoubleVal Double64-bit floating-point (double precision)
double *double *ByRef DoubleVar Double, Var Double[ ], Val Double[ ]Pointer to a single or an array of 64-bit floating-point
char[ ]sbyte[ ]ByVal Byte ( )Val String, ValChar[ ], Var Char[ ]String of NULL terminated ASCII characters
char[ ] *ByRef Byte ( )Val String, Var StringPointer to string of NULL terminated ASCII characters
wchar_t[ ]stringByVal StringVal BString, Val WChar[ ], Var WChar[ ]String of Unicode characters
VARIANTobjectByVal ObjectVal VariantDynamically-changeable data type
intintByVal IntegerVal ProcedureHolds the address of a procedure, 32 bit
IUnknown *. IDispatch *objectByVal ObjectVal ObjectCOM/NET object, stored in a 32-bit address for the COM interface


Using Val and Var Parameters

ATEasy function parameters can be either Val or Var.
  • Val: The parameter is passed 'by value'.  A local variable is made from the supplied argument.  Any changes made to a Val parameter within ATEasy will not affect the original variable.
  • Var: The parameter is passed 'by reference'.  The parameter is a reference to the supplied argument.  Any changes made to a Var parameter within ATEasy will be made to the original variable.


Using MemoryCopy() to get/set variable values

The ATEasy MemoryCopy() internal procedure can be used in ATEasy to copy variables values into ATEasy using the variable's memory address and size.

For instance, in this C++ DLL procedure a char array is created.  The function returns the location of the first element in the array (plAddress) and the array's size (plSize):

void StringTest(int *plAddress, int *plSize)
{
    static char szExample[]="Test String ABC123";
    *plAddress=(int)&szExample[0];
    *plSize=strlen(szExample);
}

The ATEasy procedure shown below calls the C++ DLL procedure, retrieving the address and size data and then uses that information to construct its own variable using MemoryCopy.  In this case, a string is the most appropriate variable.  But this technique could be used for other basic and / or user-defined variables.

Procedure MemoryCopyTest(): String Public
--------------------------------------------------------------------------------
sTest: String
lSize: Long
lAddress: Long
{
    StringTest(lAddress, lSize)
    SetLen(sTest, lSize)
    MemoryCopy(&sTest, lAddress, lSize)
    return sTest
}


Related Material

Knowledge Base: Passing Array between ATEasy and .NET
Article Date 3/16/2011 , 5/27/2021
Keywords language, reference, C, C++, C#, VB, .NET


Login to rate article

1 ratings | 5 out of 5
Read Prior Article Read Next Article
>