You are not logged in.
Pages: 1
I'm finding some errors when try to compile my project in FPC.
function TAmostraService.InsertMany(pAmostras: variant): TServiceCustomAnswer;
var
vListaAmostras: IDocList;
vItemAmostra: variant;
vAmostra: TAmostra;
begin
vAmostra := TAmostra.Create;
try
// delphi compiles, fpc no (Sorotrack.AmostraService.pas(339,23) Error: Can't determine which overloaded function to call)
vListaAmostras := DocListFrom(pAmostras.amostras);
for vItemAmostra in vListaAmostras do
begin
// delphi compiles, fpc no. what do do? Sorotrack.AmostraService.pas(343,38) Error: Incompatible types: got "OleVariant" expected "UTF8String"
vAmostra.Numero := vItemAmostra.Numero;
// delphi compiles, fpc no. what do do?
// Sorotrack.AmostraService.pas(347,31) Error: Incompatible types: got "Pointer" expected "TSolicitacao"
vAmostra.Solicitacao := Pointer(PtrInt(vItemAmostra.Solicitacao));
vAmostra.Exames := vItemAmostra.Exames;
vAmostra.DataEtiqueta := vItemAmostra.DataEtiqueta;
vAmostra.Empresa := Pointer(PtrInt(CurrentUserCompany));
Result := Add(vAmostra);
end;
finally
vAmostra.Free;
end;
end;
I've alredy read at the documentacion the part about FPC Clients here: https://synopse.info/files/html/Synopse … m*%20units , but it didn't works for me. Can someone help me with this issues?
Offline
Seems like a FPC limitation: the conversion should be explicit with late binding, like
vAmostra.Numero := VariantToUtf8(vItemAmostra.Numero);
Instead of using late binding and IDocList, I would use a PDocVariantData() and its methods.
var
vListAmostras, vItemAmostra: PDocVariantData;
..
vListAmostras := _Safe(paMostras.amostras);
for vItemAmostra in vListAmostras.Objects do
begin
vAmostra.Numero := vItemAmostra.U['Numero'];
...
end;
Offline
pAmostras: Variant receive a int64 number => Solicitacao: 123
vAmostra.Solicitacao: TAmostra(TOrm)
How can i pass this integer as TID to works in delphi and freepascal?
vAmostra.Solicitacao := Pointer(PtrInt(vItemAmostra.Solicitacao));
tnks
Offline
It is safer to define this property as a real TID and NOT a TOrm, if you don't use TOrmMany features.
It would be much less confusing.
And take a look at my code using PDocVariantData: it is safer than using late binding.
You can just write, with your TID property:
vAmostra.Solicitacao := vITemAmostra.I['Solicitacao']
Offline
There are something way to store null instead 0 on Solicitacao?
0 will raise foreign key error.
I find TNullableID or TIDNullable wothout success!
Offline
Pages: 1