BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Vb 6 to Delphi (variant arrays)

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi ObjectPascal
View previous topic :: View next topic  
Author Message
Guest






PostPosted: Thu Jul 13, 2006 2:40 am    Post subject: Vb 6 to Delphi (variant arrays) Reply with quote



I am writing an interface to a third party application. Their sample
dll is in vb (active x dll) and Id like to convert it to Delphi 6. I
have all the com wrapper stuff done such that I can get their app to
call my function but am having a heck of a time with the arrays they
want to pass back as parameters. I see all of my message boxes and am
parsing out correctly the drivers license they send me, and I see them
display my success message, but none of the data in the array returns.
Any ideas?

I think its the declaration of this:
Dim ResultArray(14, 2) As Variant
and how to handle it that I'm missing.

VB sample function:
--------
Public Function GetCrashDriverWithDID(InputArray() As Variant) As
Variant
Dim HeaderArray() As Object
Dim ParameterArray() As Variant
Dim ResultArray(14, 2) As Variant 'Second parameter determines how
many records to return. Example: resultarray(14,4) provides room for 5
different records to be returned.
Dim DriverLicenseNumber As String
Dim MsgBoxResult As Integer
Dim Serror As String
On Error GoTo CrashData_Error

DoEvents



HeaderArray() = InputArray(0)
ParameterArray() = InputArray(1)
DriverLicenseNumber = ParameterArray(0) 'Get driver license
number



Rem Replace code below to retrieve data from your data source
and use it to populate
Rem the results array. Be sure to truncate data to correct
field lengths.

ResultArray(0, 0) = "Z3320005205208" 'Driver's license
number
ResultArray(1, 0) = "" 'Prime DID "Note: ok to
return empty string if value is unknown.
ResultArray(2, 0) = "WI" 'Driver License State
ResultArray(3, 0) = "ZZZDOTIES" 'Driver Last Name
ResultArray(4, 0) = "ANTHONY" 'Driver First Name
ResultArray(5, 0) = "L" 'Driver Middle Initial
ResultArray(6, 0) = "" 'Driver Name Suffix
e.g., JR, SR
ResultArray(7, 0) = "03/24/82" 'Driver Date of Birth
MM/DD/YYYY
ResultArray(8, 0) = "M" 'Driver Sex
ResultArray(9, 0) = "100 MAIN ST" 'Driver Street Address
ResultArray(10, 0) = "123" 'Driver PO Box Number
ResultArray(11, 0) = "MADISON" 'Driver City
ResultArray(12, 0) = "WI" 'Driver State
ResultArray(13, 0) = "537051234" 'Driver Zip Code
ResultArray(14, 0) = "2008" 'Driver License
Expiration Year

ResultArray(0, 1) = "Z3327604708201" 'Driver's license number
ResultArray(1, 1) = "" 'Prime DID "Note: ok to
return empty string if value is unknown.
ResultArray(2, 1) = "WI" 'Driver License State
ResultArray(3, 1) = "ZZZDOTIES" 'Driver Last Name
ResultArray(4, 1) = "ROBERT" 'Driver First Name
ResultArray(5, 1) = "J" 'Driver Middle Initial
ResultArray(6, 1) = "" 'Driver Name Suffix
e.g., JR, SR
ResultArray(7, 1) = "03/02/47" 'Driver Date of Birth
MM/DD/YYYY
ResultArray(8, 1) = "M" 'Driver Sex
ResultArray(9, 1) = "200 MAPLE ST" 'Driver Street Address
ResultArray(10, 1) = "" 'Driver PO Box Number
ResultArray(11, 1) = "MADISON" 'Driver City
ResultArray(12, 1) = "WI" 'Driver State
ResultArray(13, 1) = "537059876" 'Driver Zip Code
ResultArray(14, 1) = "2010" 'Driver License
Expiration Year

ResultArray(0, 2) = "Z3325125896406" 'Driver's
license number
ResultArray(1, 2) = "" 'Prime DID "Note: ok to
return empty string if value is unknown.
ResultArray(2, 2) = "WI" 'Driver License State
ResultArray(3, 2) = "ZZZDOTKLR" 'Driver Last Name
ResultArray(4, 2) = "KENDRA" 'Driver First Name
ResultArray(5, 2) = "A" 'Driver Middle Initial
ResultArray(6, 2) = "" 'Driver Name Suffix
e.g., JR, SR
ResultArray(7, 2) = "12/24/58" 'Driver Date of Birth
MM/DD/YYYY
ResultArray(8, 2) = "F" 'Driver Sex
ResultArray(9, 2) = "300 JENIFER ST" 'Driver Street
Address
ResultArray(10, 2) = "" 'Driver PO Box Number
ResultArray(11, 2) = "MADISON" 'Driver City
ResultArray(12, 2) = "WI" 'Driver State
ResultArray(13, 2) = "537054567" 'Driver Zip Code
ResultArray(14, 2) = "2011" 'Driver License
Expiration Year

GetCrashDriverWithDID = Array(True, "Your search was
successful", ResultArray())

Exit Function
CrashData_Error:
Serror = "An Error : '" & Error & "' occurred in
GetCrashDriverWithDID."
Err = False
GetCrashDriverWithDID = Array(False, Serror)

End Function

-------

My Delphi 6 attempt:

----
function TCrashDataObj.GetCrashDriverWithDID(
InputArray: OleVariant): OleVariant;
var
DriversLiscenceNumber : string;
HeaderArray : array of Tobject;
ParameterArray : array of variant;
DataArray,ResultArray : variant;
Serror : string;
begin
messagedlg('GetCrashDriverWithDID',mtinformation,[mbok],0);
DataArray := VarArrayCreate([0,14], varVariant);
HeaderArray := nil;
ParameterArray := nil;
messagedlg('GetCrashDriverWithDID After Create
Arrays',mtinformation,[mbok],0);
try
{Main Code}
HeaderArray := InputArray[0];
ParameterArray := InputArray[1];
DriversLiscenceNumber := ParameterArray[0];
messagedlg('Drivers Liscence number = ' +
DriversLiscenceNumber,mtinformation,[mbok],0);
//Fill Data array
DataArray[0] := 'Z3320005205208'; //Driver's license number
DataArray[1] := ''; //Prime DID "Note: ok to
return empty string if value is unknown.
DataArray[2] := 'WI'; //Driver License State
DataArray[3] := 'ZZZDOTIES'; //Driver Last Name
DataArray[4] := 'ANTHONY'; //Driver First Name
DataArray[5] := 'L'; //Driver Middle Initial
DataArray[6] := ''; //Driver Name Suffix e.g.,
JR, SR
DataArray[7] := '03/24/82'; //Driver Date of Birth
MM/DD/YYYY
DataArray[8] := 'M'; //Driver Sex
DataArray[9] := '100 MAIN ST'; //Driver Street Address
DataArray[10] := '123'; //Driver PO Box Number
DataArray[11] := 'MADISON'; //Driver City
DataArray[12] := 'WI'; //Driver State
DataArray[13] := '537051234'; //Driver Zip Code
DataArray[14] := '2007'; //Driver License Expiration
Year
messagedlg('GetCrashDriverWithDID filling
ResultArray',mtinformation,[mbok],0);

ResultArray := VarArrayOf([0,'Your search was
successful',DataArray]);
messagedlg('GetCrashDriverWithDID before
return',mtinformation,[mbok],0);
GetCrashDriverWithDID := ResultArray;
messagedlg('GetCrashDriverWithDID
exiting',mtinformation,[mbok],0);
except on e: exception do
begin
sError := 'An Error : '''+e.message+''' has occured in
GetCrashDriverWithDID.';
ResultArray := VarArrayOf([1,sError]);
end;
end;

end;
----
Back to top
Riki Wiki
Guest





PostPosted: Sat Jul 15, 2006 8:12 am    Post subject: Re: Vb 6 to Delphi (variant arrays) Reply with quote



Hoi Driazen

This newsgroup officially closed years ago. You need to repost your
message in the b.p.delphi.language.delphi.win32 newsgroup and do so
using the Borland news server, if you want people to see it.

How to post to Delphi newsgroups:
<http://delphi.wikia.com/wiki/Delphi_Newsgroups>
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> Delphi ObjectPascal All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.