OleVariant: The compiler does not automatically performs the necessary type conversions.
Original Reporter info from Mantis: thierrybo
-
Reporter name:
Original Reporter info from Mantis: thierrybo
- Reporter name:
Description:
Since the recent release of LazActiveX lazarus package, I tried to replace delphi with Lazarus to work with a business dll I have to work with, using the package type library importer.
You will see in the code below that it is the same code for delphi and freepascal.
The line :
ALigneDoc.InfoLibre.Item[ANomInfoLibre] := AValInfoLibre;
raise "EOleException: Variable type mismatch." error with freepascal
Additional information:
Freepascal and Delphi Function call :
ModifieInfoLibreLigne(
CreeLigneVente(DocVente, 'BRAAR10', 1) as IBODocumentLigne3,
'Commentaires',
'Extension de garantie : 3 ans');
_________________________________________________________
Freepascal and Delphi Function declaration :
function ModifieInfoLibreLigne(
ALigneDoc : IBODocumentLigne3;
ANomInfoLibre : string;
AValInfoLibre : OleVariant): Boolean;
begin
{ Modifie une info libre d'une ligne existante : }
try
// *****************************************************
// The line below raise error :
// EOleException: Variable type mismatch.
// *******************************************
ALigneDoc.InfoLibre.Item[ANomInfoLibre] := AValInfoLibre;
ALigneDoc.Write_;
Result := true;
except on E: Exception do
begin
Writeln(E.ClassName, ': ', E.Message);
Result := false;
end;
end;
end;
-------------------------------------------------
FREEPASCAL Item declaration (excerpt) :
IBIValues = interface(IDispatch)
['{105BF8A9-F0A7-48DA-B175-53C470283114}']
property Item[vIndex:OleVariant]:OleVariant read Get_Item write Set_Item; default;
-------------------------------------------------
DELPHI Item declaration (excerpt) :
IBIValues = interface(IDispatch)
['{105BF8A9-F0A7-48DA-B175-53C470283114}']
property Item[vIndex: OleVariant]: OleVariant read Get_Item write Set_Item; default;
__________________________________________________
Mantis conversion info:
- Mantis ID: 24721
- OS: Windows
- OS Build: XP
- Platform: Win32
- Version: 2.7.1